SSH Passwordless Login Using SSH Keygen in 5 Easy Steps

Download Your Free eBooks NOW - 10 Free Linux eBooks for Administrators

Ravi Saive

Simple Word a Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux.

TecMint users Get a Free Domain and 30% off on Inmotion Web Hosting - Signup with Inmotion Now!

Download Free Linux eBooks

Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Ubuntu Linux Toolbox: 1000+ Commands

You may also like...

76 Responses

  1. server 1 ip is 192.168.1.1 and second server is 192.168.1.2 i doo all the steps but it asking me for password i set the permission to .ssh 700 and authorised_keys to 640

  2. Frank says:

    This. just. works. I couldn’t believe it would be so simple. Spent the last 2.5 hours reading dozens of different ‘tutorials’ and nothing worked, this was supposed to be such a simple 5-minute task, i was starting to doubt my own sanity. This was literally my last try, it looked almost ‘too simple’ at first but it saved my evening. Thanks a lot for posting! Frank

  3. Zeeshan Ahmed says:

    Hello,

    I have performed above steps but still ssh is asking for password, can any buddy help me on this. Thanks in Advance.

    Regards,

  4. For Ubuntu 14.04 some extra pre steps may be needed.

    1. f you messed up already the setup, remove the server 2 from known hosts to restart process.

    ssh-keygen -R hostname

    2. It is good to create the same user in both machines and run this setup as this user.

    3. Turn this user as sudoer and allowed ssh user in both servers.

    For sudoer use command

    visudo

    and copy same root previleges to this user

    For ssh:

    vi /etc/ssh/sshd_config

    at the line starting with

    AllowUsers root

    add you new user with an space in between

    AllowUsers root username

    Also check this variables, you may have to add one

    PermitRootLogin without-password
    PermitRootLogin yes
    UsePAM no

  5. Bluem says:

    Hi Ravi,

    Please see if you can help.

    i have two Linux servers, first server(lniux 5.7) ip x.y.4.112 and another linux server(6.3) ip is x.y.90.23.
    i want a ssh passwordless communication from x.y.90.23 to x.y.4.112.
    manually ssh is allowed.

    i have followed the below steps also.

    1. on server x.y.90.23
    >$ ssh-keygen -t rsa
    >$HOME/.ssh
    2. on server x.y.4.112
    >Copy content of id_rsa.pub file from x.y.90.23 server to all x.y.4.112 server in file authorized_keys under directory $HOME/.ssh/

    But still it is asking for password.
    is it because both server are on different network ?or different linux O.S? or something else.
    i tried locally with two server on the same n/w..that was working..

    Thanks in advance.

    • Ravi Saive says:

      @neelam,
      Please set the correction permissions on ‘.ssh’ directory and ‘authorized_keys’ file on remote hosts (i.e. ip 4.112 ) as shown.

      # chmod 700 .ssh
      # chmod 640 .ssh/authorized_keys
      
  6. Bluem says:

    Hi Ravi,

    Please see if you can help.

    i have two Linux servers, first server(lniux 5.7) ip x.y.4.112 and another linux server(6.3) ip is x.y.90.23.
    i want a ssh passwordless communication from x.y.90.23 to x.y.4.112.
    manually ssh is allowed.
    i have followed the below steps also.

    1. on server x.y.90.23
    >$ ssh-keygen -t rsa
    >$HOME/.ssh

  7. Diarra says:

    Hello Ravi Saive,
    I am managing a lot of servers which have each of them loggin and passwords through a ssh bastion. All servers are centOS based, the ssh bastion to is in centOS, and my laptop iis in windows.
    What I would like to do is to generate a public key on each server, and copy them to a repository in the SSH bastion and if I would like to ssh to a remote serverA, I only do a putty configuration which will permit to only tipe “ssh serverA” and I get connected.
    What would I do to have it?
    What are the configuration needed
    Thanks in advance for your help
    Regards

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Join Over 62000+ Linux Users
  1. 47558
  2. 2150
  3. 11343

Enter your email to get latest Linux Howto's