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
RHEL: Checking HBAs
Viewed 14214 times since Sun, May 27, 2018
RHEL: Getting/Setting hardware clock’s time
Viewed 2669 times since Sat, Jun 2, 2018
CentOS / RHEL : Configure yum automatic updates with yum-cron service
Viewed 3296 times since Fri, Oct 26, 2018
Setup SSL Tunnel Using Stunnel on Ubuntu
Viewed 1985 times since Fri, Sep 28, 2018
RHEL: Remove existing SAN LUNs
Viewed 13715 times since Sat, Jun 2, 2018
YUM How to use yum command on CentOS/RHEL
Viewed 6555 times since Thu, Oct 25, 2018
Nagrywanie sesji SSH do pliku
Viewed 2657 times since Thu, May 24, 2018
LVM: Remove a Filesystem / Logical Volume
Viewed 2293 times since Sat, Jun 2, 2018
KONTO SFTP Z CHROOTEM Z UŻYCIEM OPENSSH-SERVER NA CENTOS/RHEL6
Viewed 1552 times since Fri, Nov 30, 2018
tcpdump
Viewed 8728 times since Fri, Jul 27, 2018