DEV Community

Cover image for Login to VPS without a password using SSH
Mannuel
Mannuel

Posted on

Login to VPS without a password using SSH

It is possible to ssh into your Linux VPS without having to use a password.

Here are the steps:

  1. Create ssh key if you dont have one already
  2. Add the public ssh to the remote servers authorized_keys list

If you already have an ssh key skip to step 2

1 Create ssh key

Fire up the terminal and first go to your .ssh folder on your personal computer.

cd ~/.ssh
Enter fullscreen mode Exit fullscreen mode

Then type (to create the ssh key)

ssh-keygen -t rsa -b 4096 -C "your@email.com" 
Enter fullscreen mode Exit fullscreen mode

Follow the prompts

  • push enter for each question to accept the defaults
  • it will create a prive and public ssh key called id_rsa and id_rsa.pub
  • do not enter a passwords

It will look like this:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/mannuel/.ssh/id_rsa): id_rsa_test
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in id_rsa
Your public key has been saved in id_rsa.pub
The key fingerprint is:
SHA256:52n1XC/4hSWgwC8gqK0Ld0ym/fb3BBXbhHypgmQFUHI your@email.com
The key's randomart image is:
+---[RSA 4096]----+
|      ooEo...... |
|   .   +o   o=o  |
|  . . .oo.  +o.  |
| o   . ..o.o..   |
|. . o   S =.. . o|
| . *     + + + =.|
|o o +     + o = o|
|.o . ..  ... . o |
|.    ..... .. .  |
+----[SHA256]-----+
Enter fullscreen mode Exit fullscreen mode

2 Add key to authorized_keys list

 cat ~/.ssh/id_rsa.pub | ssh yourUsername@000.000.00.00 'cat >> ~/.ssh/authorized_keys'
Enter fullscreen mode Exit fullscreen mode

you will be prompted to enter your VPS password given for yourUsername.

 cat ~/.ssh/id_rsa.pub | ssh yourUsername@000.000.00.00 'cat >> ~/.ssh/authorized_keys'
 yourUsername@000.000.00.00's password: 
Enter fullscreen mode Exit fullscreen mode

Jobs done, you should be able to ssh into VPS without entering a password.

Follow me

Twitter
Website

Top comments (0)