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 list all hard disks in linux from command line
Viewed 2828 times since Mon, Jan 28, 2019
How To Use the Linux Auditing System on CentOS 7
Viewed 3596 times since Fri, Apr 5, 2019
Linux Kernel /etc/sysctl.conf Security Hardening
Viewed 23139 times since Fri, Aug 3, 2018
www.unixarena.com
Viewed 2150 times since Fri, Jul 27, 2018
Exclude multiple files and directories with rsync
Viewed 2012 times since Wed, Oct 31, 2018
awk printf
Viewed 14348 times since Wed, Aug 19, 2020
Extending Linux LVM partitions script
Viewed 6118 times since Wed, Feb 6, 2019
ZFS: Verify/change properties of a zfs filesystem
Viewed 2268 times since Sun, Jun 3, 2018
logrotate How log rotation works with logrotate
Viewed 8558 times since Sun, Jan 12, 2020
RHCS6: Clustered LVM
Viewed 1889 times since Sun, Jun 3, 2018