All Articles

SSH login using key only

Connect to remote server using local machine/client ssh key for authentication.

  1. Generate SSH key using the command ssh-keygen in OS X and Linux terminal if is not already generated at /.ssh. Window user can use PuttyGen.
  2. Copy client ssh key to remote machine authorizedkey file
    `cat ~/.ssh/id
    rsa.pub | ssh user@123.45.56.78 “mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys`
  3. Edit remote machine /etc/ssh/sshd_config PasswordAuthentication no RSAAuthentication yes PubkeyAuthentication yes

Bonus: Generate server private key for anywhere access using key only

  1. Generate key on server ssh-keygen
  2. Put the key into authorizedkey file echo \cat ~/.ssh/uploadedkey.pub` >> ~/.ssh/authorized_keys`
  3. Copy key from machine to local machine using SCP scp user@192.168.0.103:/home/user/.ssh/id_rsa ~/user/Desktop (Edit the username, IP address and folder accordingly)
  4. Convert the id_rsa file to putty file for use in Putty
  5. Connect using Putty