0

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

  • Did you just post your private keys on the internet? – HackSlash Dec 6 '18 at 21:59
  • @HackSlash It is not private key and It is trimmed as you can see – Tarun Dec 7 '18 at 7:03
2

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:

Each line in these files contains the following fields: markers (optional), hostnames, keytype, base64-encoded key, comment. The fields are separated by spaces. […] Hostnames is a comma-separated list of patterns (‘*’ and ‘?’ act as wildcards); each pattern in turn is matched against the host name. […] A hostname or address may optionally be enclosed within ‘[’ and ‘]’ brackets then followed by ‘:’ and a non-standard port number.

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.

  • How to generate ssh-dss key for any host – Tarun Dec 4 '18 at 6:24
  • 1
    You don't generate it, you copy the key that the host already uses. There is no magic "any host" key. – grawity Dec 4 '18 at 6:29
  • i am using jboss EAP, a simple web application server which is running on localhost, where to find ssh-dss key ? – Tarun Dec 4 '18 at 7:16
  • 2
    If your app is running on localhost, then the SSH host itself is localhost. Use your own computer's key then, e.g. from ssh-keyscan -t dsa localhost. – grawity Dec 4 '18 at 7:47
  • i run this command on git bash on my computer Desktop. but it nothing is displaying on command line. – Tarun Dec 4 '18 at 8:40
0

Try sshing into your target, and then type yes when it asks to save the key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.