cs101:generatesshkeys
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
cs101:generatesshkeys [2018/11/09 18:20] – [2. Generate Keys] localadmin | cs101:generatesshkeys [2018/11/09 18:31] (current) – [2. Generate Keys] localadmin | ||
---|---|---|---|
Line 17: | Line 17: | ||
Don't forget to open the proper port (default is 22) in the firewall to allow external connections. | Don't forget to open the proper port (default is 22) in the firewall to allow external connections. | ||
+ | |||
==== 2. Generate Keys ==== | ==== 2. Generate Keys ==== | ||
- | Nest you need to generate a set of keys (public & private) for your local computer. Run the following commands (for OpenSSH | + | Nest you need to generate a set of keys (public & private) for your local computer. Run the following commands (based on OpenSSH for Ubuntu). |
mkdir ~/.ssh | mkdir ~/.ssh | ||
Line 29: | Line 30: | ||
The first command creates a hidden .ssh directory in your home folder, the second changes the access permissions of the folder, while the third command generates a set of RSA keys. | The first command creates a hidden .ssh directory in your home folder, the second changes the access permissions of the folder, while the third command generates a set of RSA keys. | ||
- | You’ll be asked for a location to save the keys (leave blank and press enter to save in the default .ssh directory location) and then for a passphrase. | + | You will be asked for a location to save the keys (leave blank and press enter to save in the default .ssh directory location) and then you'll be asked for a passphrase. |
This passphrase further encrypts the private key that’s stored on your computer, giving you more time to secure the SSH server if your private key is ever stolen. Make sure you choose a passphrase you’re able to remember, as you’ll have to enter it when you use your key. | This passphrase further encrypts the private key that’s stored on your computer, giving you more time to secure the SSH server if your private key is ever stolen. Make sure you choose a passphrase you’re able to remember, as you’ll have to enter it when you use your key. | ||
Line 40: | Line 41: | ||
ssh-copy-id < | ssh-copy-id < | ||
| | ||
- | Where < | + | Where < |
If your client doesn’t support the ssh-copy-id command, you can use the following command instead. It’s more convoluted, but achieves the same results. | If your client doesn’t support the ssh-copy-id command, you can use the following command instead. It’s more convoluted, but achieves the same results. | ||
Line 48: | Line 49: | ||
You will be asked to enter the your user password for the SSH server. If the commands finishes without errors, your public key will have been copied to the SSH server. | You will be asked to enter the your user password for the SSH server. If the commands finishes without errors, your public key will have been copied to the SSH server. | ||
+ | |||
+ | ==== 4. Disable Password Authentication ==== | ||
+ | |||
+ | Your SSH server system still isn’t more secure than when you started step one. Although at least one client computer is configured to use key-based authentication, | ||
+ | |||
+ | To disable password authentication, | ||
+ | |||
+ | sudo nano / | ||
+ | |||
+ | Find the line | ||
+ | |||
+ | # | ||
+ | |||
+ | Remove the number sign (#) and change the setting to ‘no’, as below. | ||
+ | |||
+ | PasswordAuthentication no | ||
+ | |||
+ | Save the file by pressing CTRL+X (if using nano). Confirm the edit and the filename and you’re done editing the SSH server' | ||
+ | |||
+ | sudo restart ssh | ||
+ | |||
+ | You will notice that your client will stop asking for the passphrase to decrypt your key if password authentication is disabled on the server. | ||
cs101/generatesshkeys.1541787609.txt.gz · Last modified: by localadmin