The known_hosts file looks like this :-
[localhost]:8001 ssh-dss AAAAB3NzaC1kc3MAAACBAP1/U4EddRIpU
[10.18.60.198]:8001 ssh-dss AAAAB3NzaC1kc3MAAACBAP1/U4EddRIpUt9
// key are trimmed at the end
This keys are added via Eclipse IDE, Want to know what are other ways to add hosts (IPs) and their keys to ssh/known_hosts file.
Specific:- How to add ssh-dss key for any host(IP) in known_hosts file.
EDIT:-
I am using JBoss BRMS which uses git for BRMS Projects, So at time of cloning the BRMS Project in Eclipse IDE via Git it gives following error
The authenticity of host 'localhost' can't be established.
DSA key fingerprint is e2:2c:62 //trimmed.
Are you sure you want to continue connecting?
And it then automatically add ssh-dss key to known_hosts file.
So where to find that key and add it manually on knownhosts file
Best Answer
The format of
~/.ssh/known_hosts
is defined by OpenSSH. Other software might either call OpenSSH (the ssh command), or might have its own implementations that aren't necessarily 100% compatible.The OpenSSH known_hosts format is described in the sshd(8) manual page, under "ssh_known_hosts file format". It says that it's a text file with one line per host–key pair:
To automatically add a key for a new host, just SSH to it.
To manually add a key for a new host, 1) open the known_hosts file in your text editor and 2) add the key for a new host, following the same format. (The key must match the host you're connecting to. You can query a host for its key using
ssh-keyscan -t <type> <address>
.)To add a key for all hosts, use a
*
pattern as the hostname, which will match all hostnames and addresses. To add a key for all hosts on a specific port, use[*]:8001
as the hostname.