- Generate Public and Private Keys
- Copy Public Key to the target machine
- Set appropriate permissions
- Create Configuration File for auto login
SSH keys allow you to login into your SSH server without having to remember passwords and with much stronger security. It’s like having a super long password that you never have to remember… Just keep your private keys in a safe place.
Generate Public and Private Keys
Generate public keys. The command will produce two keys, one public (
~/.ssh/example.com-id.pub) and one private (
Copy Public Key to the target machine
Your remote server needs to know your public key, so you need to send it there.
Set appropriate permissions
Your private key should only be visible to you and not other users, otherwise
ssh will complain and not allow you to use the keys.
Create Configuration File for auto login
This config file will tell
ssh where are the configurations for an alias for your now key-authenticated server.
Example contents of the new file
Login using machine identifier
Now you can login using
ssh and the alias you choose in the config file above.
Save your keys and configuration file in a “safe place” for later
You can login from other computers using the same public key without having to configure the server again. All you need is to copy:
- The public (
~/.ssh/example.com-id.pub) and private keys (
~/.ssh directory in the new machine.
Disable remote login using passwords
Search for the line below and uncomment
Restart the sshd service
Remember, if others also get these keys and configuration file they can log into your server!