{Linux Tips} SSH Keys Edition: Setting Up and Using SSH Keys for Password-Free Logins 09-21-2014, 03:02 AM
#1
It's that time again for another Linux Tips! In today's tip we're going to talk about ssh keys and using them for password-free logins. This tip requires a linux workstation (the system you're sitting at) and a destination system running linux as well (since we're using ssh here).
For starters, you need to generate an SSH key on your workstation. Each user on that system can have their own key. To do this, open a terminal as the user you want to setup the key for and run:
You can leave the passphrase blank for this exercise, and leave the rest of the settings default as well.
Once the key generation completes, you're halfway there.
The next step is to copy your newly generated SSH key to your destination server. This can be completed with the ssh-copy-id command. The command will look something like this:
So, what we see here is the user "user" on the local machine is running the ssh-copy-id command and passing username at the remote machine. These usernames do not need to match, so you could be "bob" on localhost, and "root" on remotehost.
once you run that command, you will be prompted for the REMOTE USERS password. Type the password, ssh-copy-id will work it's magic, and give you some output. Now, if you run ssh username@remotehost.tld, you can log in without being prompted for a password!
I hope this was helpful and interesting. You can use this knowledge to help harden ssh on your remote system by looking through the sshd_config files. Perhaps we'll discuss that in a future Linux Tips .
For starters, you need to generate an SSH key on your workstation. Each user on that system can have their own key. To do this, open a terminal as the user you want to setup the key for and run:
Code:
ssh-keygen
You can leave the passphrase blank for this exercise, and leave the rest of the settings default as well.
Once the key generation completes, you're halfway there.
The next step is to copy your newly generated SSH key to your destination server. This can be completed with the ssh-copy-id command. The command will look something like this:
Code:
user@localhost~$: ssh-copy-id username@remotehost.tld
So, what we see here is the user "user" on the local machine is running the ssh-copy-id command and passing username at the remote machine. These usernames do not need to match, so you could be "bob" on localhost, and "root" on remotehost.
once you run that command, you will be prompted for the REMOTE USERS password. Type the password, ssh-copy-id will work it's magic, and give you some output. Now, if you run ssh username@remotehost.tld, you can log in without being prompted for a password!
I hope this was helpful and interesting. You can use this knowledge to help harden ssh on your remote system by looking through the sshd_config files. Perhaps we'll discuss that in a future Linux Tips .
---
Click here to get started with Linux!
If I helped you, please +rep me, apparently we've started over on Rep and I'd like to break 100 again...
Click here to get started with Linux!
If I helped you, please +rep me, apparently we've started over on Rep and I'd like to break 100 again...
Inori Wrote: got clickbaited by roger