Login to VPS without a password using SSH

M Ferreira
M Ferreira

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

First go to you .ssh folder

cd ~/.ssh

Then type (to create the ssh key)

ssh-keygen -t rsa -b 4096 -C "your@email.com"

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]-----+

2 Add key to authorized_keys list

cat ~/.ssh/id_rsa.pub | ssh yourUsername@000.000.00.00 'cat >> ~/.ssh/authorized_keys'

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:

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

Stay up to date

Consider keeping up to date with software development and design by signing up to my newsletter.

I will only email you when I make a new post.