| | 1 | = Set up SSH public-key authentication = |
| | 2 | |
| | 3 | Using SSH public-key authentication to connect to a remote system is a robust, more secure alternative to logging in with an account password. |
| | 4 | |
| | 5 | See if you have public-key generated. |
| | 6 | |
| | 7 | {{{ |
| | 8 | local:~ user$ ls ~/.ssh |
| | 9 | config id_rsa id_rsa.pub known_hosts |
| | 10 | }}} |
| | 11 | |
| | 12 | |
| | 13 | |
| | 14 | ***.pub is your public-key. If you don't have it, |
| | 15 | {{{ |
| | 16 | local:~ user$ ssh-keygen -t rsa |
| | 17 | }}} |
| | 18 | |
| | 19 | You will be prompted to supply a filename (for saving the key pair) and a passphrase (for protecting your private key): |
| | 20 | |
| | 21 | Filename: To accept the default filename (and location) for your key pair, press Enter or Return without entering a filename. |
| | 22 | Password: If you press Enter or Return without entering a passphrase, your private key will be generated without password-protection. |
| | 23 | |
| | 24 | SCP to copy the public key file (e.g., ~/.ssh/id_rsa.pub) to your account on the remote system (e.g., usersID@cypress.tulane.edu); |
| | 25 | {{{ |
| | 26 | local:~ user$ scp ~/.ssh/id_rsa.pub usersID@cypress.tulane.edu: |
| | 27 | }}} |
| | 28 | Don't forget ':' |
| | 29 | You'll be prompted for your account password. Your public key will be copied to your home directory (and saved with the same filename) on the remote system. |
| | 30 | |
| | 31 | |
| | 32 | |
| | 33 | |
| | 34 | Log into Cypress using your account username and password. |
| | 35 | {{{ |
| | 36 | local:~ user$ ssh userID@cypress.tulane.edu |
| | 37 | }}} |
| | 38 | |
| | 39 | You must have "id_rsa.pub" on your home directory |
| | 40 | |
| | 41 | {{{ |
| | 42 | [user@cypress ~ $] ls id_rsa.pub |
| | 43 | id_rsa.pub |
| | 44 | }}} |
| | 45 | |
| | 46 | On the remote system, add the contents of your public key file (e.g., ~/id_rsa.pub) to a new line in your ~/.ssh/authorized_keys file; on the command line, enter: |
| | 47 | {{{ |
| | 48 | [user@cypress ~ $] cat ~/id_rsa.pub >> ~/.ssh/authorized_keys |
| | 49 | }}} |
| | 50 | |
| | 51 | You may now safely delete the public key file (e.g., ~/id_rsa.pub) on Cypress; on the command line, enter: |
| | 52 | |
| | 53 | {{{ |
| | 54 | rm ~/id_rsa.pub |
| | 55 | }}} |
| | 56 | Now you should be able to login Cypress without typing password from next time. |