SSH login with Key

From HateotU

SSH login with Key

Generate ssh key

  • Run ssh-keygen and follow the instructions
ssh-keygen

Copy Key to host

  • If login with password is enabled for the user you want to login with your key, simply type:
ssh-copy-id <username_you_want_to_login_as>@<host>
  • If you can't login with a password, anybody that has already copied his key to the host has to login and manually add your ssh key.
  • To get your ssh key, type:
cat /home/<your_username>/.ssh/id_rsa.pub
  • The person who can login has to add your ssh key at the end of the file /home/<username>/.ssh/authorized_keys
vi /home/<username_you_want_to_login_as>/.ssh/authorized_keys