ssh_keys
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| ssh_keys [2016/05/03 06:46] – created luke7858 | ssh_keys [2024/05/23 07:26] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | === Creating keys === | ||
| <sxh bash> | <sxh bash> | ||
| ssh-keygen | ssh-keygen | ||
| Line 15: | Line 16: | ||
| 01: | 01: | ||
| </ | </ | ||
| + | \\ | ||
| + | === Copying public keys to device === | ||
| Now we need to copy the public key onto the server | Now we need to copy the public key onto the server | ||
| <sxh bash> | <sxh bash> | ||
| ssh-copy-id -i ~/ | ssh-copy-id -i ~/ | ||
| </ | </ | ||
| + | If the server has a custom port: | ||
| + | <sxh bash> | ||
| + | ssh-copy-id -i ~/ | ||
| + | </ | ||
| + | \\ | ||
| + | === Logging in using private key === | ||
| You can then log into the device using the private key: | You can then log into the device using the private key: | ||
| <sxh bash> | <sxh bash> | ||
| ssh -i ~/ | ssh -i ~/ | ||
| </ | </ | ||
| - | If the private key matches the public key located on the server then it will allow you to log in! | + | If the private key matches the public key located on the server then it will allow you to log in!# |
| + | \\ | ||
| + | \\ | ||
| + | \\ | ||
| + | === Creating ssh alias === | ||
| + | Now we can make our lives a little easier so we do not have to specify the key each time: | ||
| <sxh bash> | <sxh bash> | ||
| + | vim ~/ | ||
| </ | </ | ||
| <sxh bash> | <sxh bash> | ||
| + | Host ServerName | ||
| + | Hostname x.x.x.x | ||
| + | User Luke | ||
| + | Port 22 #or you can specify custom port | ||
| + | IdentityFile ~/ | ||
| + | </ | ||
| + | You will now be able to ssh into a device with the shortcut: | ||
| + | <sxh bash> | ||
| + | ssh ServerName | ||
| + | </ | ||
| + | \\ | ||
| + | \\ | ||
| + | === Locking Down to Keys-Only === | ||
| + | Next we could potentially lock down the server so ONLY keys work. | ||
| + | \\ | ||
| + | Add the following to / | ||
| + | <sxh bash> | ||
| + | PasswordAuthentication no | ||
| </ | </ | ||
| + | Then make sure you reload the configuration file. | ||
| + | \\ | ||
| + | \\ | ||
| + | WARNING: Keep one session open and attempt to log in from a different session, this allows you to get back in if you made an incorrect update | ||
ssh_keys.1462258001.txt.gz · Last modified: 2024/05/23 07:26 (external edit)
