| 2 | |
| 3 | |
| 4 | 1. Create ssh key at localhost |
| 5 | {{{ |
| 6 | ssh-keygen -t rsa -b 4096 -C user@remotehost.com |
| 7 | }}} |
| 8 | Then they will ask to enter default .ssh path |
| 9 | {{{ |
| 10 | Enter file in which to save the key (/home/yourusername/.ssh/id_rsa): |
| 11 | }}} |
| 12 | We can key in any passphrase to make extra security but just press enter with empty key it will automate gen-key for you |
| 13 | {{{ |
| 14 | Enter passphrase (empty for no passphrase): |
| 15 | }}} |
| 16 | Now the public and private key will be kept in |
| 17 | {{{ |
| 18 | ls -al |
| 19 | /home/yourusername/.ssh/id_rsa /home/yourusername/.ssh/id_rsa.pub |
| 20 | }}} |
| 21 | |
| 22 | 2. In your local host copy public key (id_rsa.pub) to remote host |
| 23 | {{{ |
| 24 | ssh-copy-id remote_username@server_ip_address |
| 25 | }}} |
| 26 | or with manual ssh with |
| 27 | {{{ |
| 28 | 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" |
| 29 | }}} |
| 30 | |
| 31 | 3. Now you can ssh with out prompt for password |
| 32 | |