How to get access to a server through SSH without password: Public Key Authentication

If you get access to your servers through SSH then getting to a server without entering password every time can be very convenient. This tutorial teaches how to connect to a server without entering password.

First log in to the server and check if /etc/ssh/sshd_config has

PubkeyAuthentication no
entry. By default it shouldn't be there. But if it's there, change it to yes

Then go in home directory of the user on the client machine that will work with the server and check if permissions to .ssh catalog have value 700 or change it just in case:

chmod 700 /home/user/.ssh

Logged in with this user ( without sudo ) do the following:

cat ~/.ssh/ | ssh user@server "mkdir -p .ssh; chmod 700 .ssh; cat >> .ssh/authorized_keys"

Here we create a couple of keys to access the server through SSH and copy our public-key to the server.
To check if it worked do:

ssh user@server

If you did it all correct you should be able to get access the server without entering password.

Got a comment?

captcha =


  1. System (20)
    1. FreeBSD (5)
    2. Linux (9)
  2. Email (2)
  3. DNS (2)
  4. Databases (1)
  5. WebServer (27)
Copyright © 2024 HowToUnix - *nix Howtos and Tutorials
All Rights Reserved.