Is there a way to generate or reinstall some package to get the contents of ~/.ssh/known_hosts file ?
- 829,060
- 12,356
2 Answers
Whenever you connect to an unknown host ssh will prompt you
The authenticity of host '...' can't be established.
RSA key fingerprint is ...
Are you sure you want to continue connecting (yes/no)?
and add a new entry to the file known_hosts file.
So to regenerate the file connect to your usual hosts and optionally check the fingerprint if you suspect a MITM.
- 5,946
-
3It's usually easiest to just login and let
sshupdateknown_hosts, but if for some reason you want to add the key(s) for some hosts(s) without logging-in, usessh-keyscan(see its man page). EDIT: as covered in another but unlinked Q by same OP http://unix.stackexchange.com/questions/349818/how-to-get-rsa-fingerprint-of-a-remote-site-in-debian – dave_thompson_085 Mar 07 '17 at 21:44
You can copy the hosts from someonewhocares.org/hosts to your /etc/hosts file , this file is updated periodically (Last updated: Tue, 07 Mar 2017 at 07:19:43 GMT)
Use this file to prevent your computer from connecting to selected internet hosts. This is an easy and effective way to protect you from many types of spyware, reduces bandwidth use, blocks certain pop-up traps, prevents user tracking by way of "web bugs" embedded in spam, provides partial protection to IE from certain web-based exploits and blocks most advertising you would otherwise be subjected to on the internet.
You can add a new entry to your known_hosts
ssh host.example.org -o "VerifyHostKeyDNS=yes"
You can verify the fingerprint :
ssh-keyscan host.example.org | ssh-keygen -lf -
- 66,769
-
1If you just want to add a known hosts entry for a host,
ssh host.example.org -o "StrictHostKeyChecking=no" true, so it returns straight away. That might be useful within aforloop, for example, to re-create lots of known-hosts entries (providing you're willing to accept the risk of spoofing whilst you're re-creating it). It's still going to be faster and more efficient to usessh-keyscaninstead, though. – Toby Speight Mar 08 '17 at 13:24
– shirish Mar 07 '17 at 19:20[$] ll -h known_hosts [0:58:49] -rw-r--r-- 1 shirish shirish 284 2017-03-07 23:41 known_hostsknown_hoststo prevent connecting to a malicious domain ? – GAD3R Mar 07 '17 at 21:38