添加公钥到known_hosts文件


ssh-keyscan host 

https://superuser.com/questions/971766/adding-a-public-key-to-known-hosts-file

Manual page for sshd(8) describes the format of known_hosts file:

Each line in these files contains the following fields: markers (optional), hostnames, bits, exponent, modulus, comment. The fields are separated by spaces.

If your public key for your host looks like this:

ssh-rsa AAAA1234.....=

So just putting this line into your ~/.ssh/known_hosts file:

your.host.name,0.0.0.0 ssh-rsa AAAA1234.....=

where you will exchange hostname and ip for your host.

Now it depends if you have ssh option HashKnownHosts turned on. If not, you are done. Otherwise you will need to hash this file usingssh-keygen -H ~/.ssh/known_hosts.

你可能感兴趣的:(python)