ssh Cheat Sheet

View fingerprint of server ssh key
ssh-keygen -lf /etc/ssh/ssh_host_dsa_key.pub
ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub

View fingerprint of server key in known_hosts
ssh-keygen -l -F [hostname or IP address]

Remove server key from known_hosts
ssh-keygen -R [hostname or IP address]

Generate keypair (not sure why, but I prefer dsa – old habit, I guess)
ssh-keygen -t dsa
ssh-keygen -t rsa

Copy pub key to a server
ssh-copy-id username@server

  1. Benjie

    December 13, 2010 at 11:01 am

    Generate a key:
    ssh-keygen -t rsa

    Get passwordless access to a remote server using said key:
    ssh user@server “cat >> ~/.ssh/authorized_keys2” < ~/.ssh/id_rsa.pub

    1. AltJ

      December 13, 2010 at 11:23 am

      Thanks Benjie
      I’ll add them, I think I prefer to move my pub keys over with ssh-copy-id

Comments are closed.