linux ssh How to Hide the OpenSSH Version Details when Telnet to Port 22

Information

How to hide the OpenSSH version details when telnet to port 22 in Red Hat Enterprise Linux?

Details

OpenSSH version details are displayed from the file /usr/sbin/sshd. The only method to hide the version detail is to edit the binary file /usr/sbin/sshd and remove/overwrite the appropriate line.

Steps:

  1. Copy the file /usr/sbin/sshd to /tmp.

    #cp /usr/sbin/sshd /tmp         
    #ksh -o vi         

  2. Find the location of text OpenSSH in it using strings command.

    Look for text SSH-2.0-OpenSSH_4.x since it is the version showed in telnet output.

    #cd /tmp  
    #strings -t d -a -n 7 sshd | grep -i openssh 
    308104 OpenSSH_4.3p2-FC-4.3p2-36.el5_4.2
    310376 hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160
    @openssh.com,hmac-sha1-96,hmac-md5-96
    310768 OpenSSH_4.3p2
    311452 OpenSSH_4.3

  3. Remove 311452 OpenSSH_4.3 line from the above output using dd command.

    #dd if=./sshd bs=1 skip=311452 count=11 | od -A n -c
    11+0 records in
    11+0 records out
    11 bytes (11 B) copied, 0.000929952 seconds, 11.8 kB/s
      O   p   e   n   S   S   H   _   4   .   3  
    #dd if=./sshd bs=1 count=311452 of=sshd.1
    311452+0 records in
    311452+0 records out
    311452 bytes (311 kB) copied, 3.77178 seconds, 82.6 kB/s
    #dd if=./sshd bs=1 skip=311452 count=11 of=sshd.2
    11+0 records in
    11+0 records out
    11 bytes (11 B) copied, 0.000568408 seconds, 19.4 kB/s
    #dd if=./sshd bs=1 skip=311463 count=999999999 of=sshd.3
    96889+0 records in
    96889+0 records out
    96889 bytes (97 kB) copied, 1.69652 seconds, 57.1 kB/s
    OpenSSH_4.3 is now cut and copied to sshd.2 file.

  4. Check the content of sshd.2 file using the od command.

    #od -A n -c sshd.2
      O   p   e   n   S   S   H   _   4   .   3  

  5. Write the text ItsHidden to sshd.2 and check the file size change before and after.

    #ls -l sshd.2
    -rw-r--r-- 1 root root 11 May  6 14:11 sshd.2
    #print -n ItsHidden > sshd.2
    #ls -l sshd.2
    -rw-r--r-- 1 root root 11 May  6 14:12 sshd.2

  6. Combine all the above sshd files to sshd.new.

    #cat sshd.* > sshd.new

  7. Give execute permission sshd.new and replace the sshd binary with sshd.new.

    #chmod 755 ./sshd.new    
    #cp /usr/sbin/sshd /usr/sbin/sshd.bak  
    #rm /usr/sbin/sshd  
    #cp /tmp/sshd.new /usr/sbin/sshd

  8. Restart sshd service and test the outcome with telnet command.

    #service sshd stop  
    #ps aux | grep -i sshd  
    #kill -9 <pid_sshd>  
    #service sshd restart  
    #telnet localhost 22  

0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments (1)
Comment By paolo - Thu, Jan 4th, 2024 9:51 AM
on centos7 "print -n ItsHidden > sshd.2" , command does not exist how can solve it?
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
How to recover error - Audit error: dispatch err (pipe full) event lost
Viewed 25441 times since Tue, Aug 6, 2019
Using renice and taskset to manage process priority and CPU affinity with Linux OEL 6.4
Viewed 3516 times since Mon, Feb 17, 2020
RHEL: Route network packets to go out via the same interface they came in
Viewed 2949 times since Sat, Jun 2, 2018
How to mount software RAID1 member using mdadm
Viewed 2956 times since Wed, Oct 3, 2018
RHEL: Remove existing SAN LUNs
Viewed 13981 times since Sat, Jun 2, 2018
stunnel How To Set Up an SSL Tunnel Using Stunnel on Ubuntu
Viewed 1629 times since Sun, Dec 6, 2020
Using Official Redhat DVD as repository
Viewed 11068 times since Mon, Oct 29, 2018
stunnel: Authentication
Viewed 9091 times since Fri, Sep 28, 2018
Transform XML to CSV Format | Unix String Pattern Manipulation The Ugly Way
Viewed 5198 times since Sun, Jan 9, 2022
RHEL: Resize/disable /dev/shm filesystem
Viewed 14622 times since Sun, May 27, 2018