Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ssh_config & sshd_config :: Examples and notes on Configuration settings
- ===========================================================================
- To import a target's ssh-pubkey
- -------------------------------
- ssh-keygen -R [hostname]
- ssh-keygen -R [ip_address]
- ssh-keygen -R [hostname],[ip_address]
- ssh-keyscan -H [hostname],[ip_address] >> ~/.ssh/known_hosts
- ssh-keyscan -H [ip_address] >> ~/.ssh/known_hosts
- ssh-keyscan -H [hostname] >> ~/.ssh/known_hosts
- To remove (#6, line 6) from 'known_hosts' file (using `sed`)
- ------------------------------------------------------------
- #> sed -i '6d' ~/.ssh/known_hosts
- To remove (#6, line 6) from 'known_hosts' file (using `perl`)
- -------------------------------------------------------------
- #> perl -pi -e 's/\Q$_// if ($. == 6);' ~/.ssh/known_hosts
- The below will do the trick to add a host, ONLY if it has not yet been added. It is also not concurrency safe; you must not execute the snippet on the same origin machine more than once at the same time, as the tmp_hosts file can get clobbered, ultimately leading to the known_hosts file becoming bloated... [[http://serverfault.com/questions/132970/can-i-automatically-add-a-new-host-to-known-hosts]]
- ---
- $> ssh-keyscan -t rsa,dsa HOST 2>&1 | sort -u - ~/.ssh/known_hosts > ~/.ssh/tmp_hosts
- mv ~/.ssh/tmp_hosts ~/.ssh/known_hosts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement