Score:1

How to edit /usr/sbin/sshd File

om flag

Prevent SSH from advertising its version number

Here is what i am doing

cp /usr/sbin/sshd /tmp

ksh -o vi

cd /tmp

strings -t d -a -n 7 sshd | grep -i openssh

After i am getting this output

 149143 0@openssH
 244802  OPENSSHI
 244972 openssh-H9
 496496 OpenSSH_7.6p1 Ubuntu-4ubuntu0.7
 499144 ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
 499440 chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
 499552 umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
 500399 OpenSSH_7.6p1
 500624 OpenSSH_7.6
 501314 none,zlib@openssh.com
 501504 hostkeys-00@openssh.com
 511114 eow@openssh.com
 511283 tun@openssh.com
 511361 no-more-sessions@openssh.com
 511390 hostkeys-prove-00@openssh.com
 511501 keepalive@openssh.com
 512112 direct-streamlocal@openssh.com
 512840 streamlocal-forward@openssh.com
 512984 cancel-streamlocal-forward@openssh.com
 522092 SIG@openssh.com
 522944 auth-agent-req@openssh.com
 538476 posix-rename@openssh.com
 538501 fstatvfs@openssh.com
 538522 hardlink@openssh.com
 538543 fsync@openssh.com
 543975 openssh-key-v1
 544186 ssh-rsa-cert-v01@openssh.com
 544224 ssh-dss-cert-v01@openssh.com
 544944 -----BEGIN OPENSSH PRIVATE KEY-----
 544984 -----END OPENSSH PRIVATE KEY-----
 545104 ssh-ed25519-cert-v01@openssh.com
 545144 ecdsa-sha2-nistp256-cert-v01@openssh.com
 545192 ecdsa-sha2-nistp384-cert-v01@openssh.com
 545240 ecdsa-sha2-nistp521-cert-v01@openssh.com
 547288 forwarded-streamlocal@openssh.com
 553384 auth-agent@openssh.com
 557682 aes128-gcm@openssh.com
 557705 aes256-gcm@openssh.com
 557728 chacha20-poly1305@openssh.com
 557760 OpenSSH-2.0*,OpenSSH-2.1*,OpenSSH_2.1*,OpenSSH_2.2*
 558192 OpenSSH_2.5.0p1*,OpenSSH_2.5.1p1*
 558232 OpenSSH_2.5.0*,OpenSSH_2.5.1*,OpenSSH_2.5.2*
 558280 OpenSSH_2.*,OpenSSH_3.0*,OpenSSH_3.1*
 559218 OpenSSH_2.3.0*
 559233 OpenSSH_2.3.*
 559247 OpenSSH_2.5.3*
 559262 OpenSSH_3.*
 559287 OpenSSH_4*
 559298 OpenSSH_5*
 559309 OpenSSH_6.6.1*
 559324 OpenSSH_6.5*,OpenSSH_6.6*
 559350 OpenSSH*
 567968 umac-64@openssh.com
 567988 umac-128@openssh.com
 568009 hmac-sha1-etm@openssh.com
 568035 hmac-sha1-96-etm@openssh.com
 568064 hmac-sha2-256-etm@openssh.com
 568094 hmac-sha2-512-etm@openssh.com
 568124 hmac-md5-etm@openssh.com
 568149 hmac-md5-96-etm@openssh.com
 568177 umac-64-etm@openssh.com
 568201 umac-128-etm@openssh.com

I am getting the output version 496496 OpenSSH_7.6p1 Ubuntu-4ubuntu0.7 in client

I don't know how to edit this one, actually i am new with this environment.Can anyone please guide me to edit this.tnx

Romeo Ninov avatar
in flag
Does this answer your question? [Prevent SSH from advertising its version number](https://serverfault.com/questions/216801/prevent-ssh-from-advertising-its-version-number)
Ray Butterworth avatar
sd flag
Is there some point to listing those first three commands?
Score:3
in flag

The file /usr/sbin/sshd is binary so you can't edit it so easy. If you want to change the behavior of sshd daemon you can edit /etc/ssh/sshd_config file (and restart the daemon).

If you want to go deep and edit something inside (which do not have configuration parameter) you can get the source, edit it and compile.

About remove version number check this Q/A

Here is one Q/A how to edit the binary file directly but I will not recommend this way.

PDAVID avatar
om flag
Is it Possible to edit with dd command.I know it's complex,just asking.
Romeo Ninov avatar
in flag
@PDAVID, second link
Score:0
sy flag

I think you can use command: "sudo sed -i 's/OpenSSH_7.6p1/OpenSSH_8.4/g' /usr/sbin/sshd ; sudo service sshd restart" to change the version and restart sshd serveice to make it effctive. also, suggest to backup sshd file before file edit.

raj avatar
ye flag
raj
One should never use commands like `sed` to edit binary files. Moreover, one should never replace a string in binary file with a different length string ("OpenSSH_7.6p1" is two characters longer than "OpenSSH_8.4"), as this will most probably damage the code and stop the file from working.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.