wiki:SSHKEYGEN

Version 8 (modified by krit, 4 years ago) (diff)

--

SSH KEY GEN

  • 1. Create ssh key at localhost
ssh-keygen -t rsa -b 4096 -C user@remotehost.com

Then they will ask to enter default .ssh path

Enter file in which to save the key (/home/yourusername/.ssh/id_rsa):

We can key in any passphrase to make extra security but just press enter with empty key it will automate gen-key for you

Enter passphrase (empty for no passphrase):

Now the public and private key will be kept in

ls -al
/home/yourusername/.ssh/id_rsa /home/yourusername/.ssh/id_rsa.pub
  • 2. In your local host copy public key (id_rsa.pub) to remote host
ssh-copy-id remote_username@server_ip_address

or with manual ssh with

cat ~/.ssh/id_rsa.pub | ssh remote_username@server_ip_address "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
  • 3. Now you can ssh with out prompt for password