DEV Community

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

Posted on

1

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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay