Skip to main content

Passwordless ssh login

Hello,

Thanks for visiting RvKmR.blogspot.in

In this blog post, I am explaining about configuring passwordless ssh login.

I setup two vms on vagrant environment, name and IP address of respective machines is listed below. I am using image "Ubuntu 14.04.5 LTS "

alpha-ubuntu      10.0.0.10
beta-ubuntu        10.0.0.11


At this stage I am logged in to machine alpha-ubuntu. When I login from alpha-ubuntu to beta-ubuntu, it ll ask for password for respective logging in user. lets check it out.

vagrant@alpha-ubuntu:~$ ssh beta-ubuntu
The authenticity of host 'beta-ubuntu (10.0.0.11)' can't be established.
ECDSA key fingerprint is 06:8d:d6:6d:a1:07:8e:19:2d:1a:2e:5c:b8:0a:0b:f5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'beta-ubuntu' (ECDSA) to the list of known hosts.
vagrant@beta-ubuntu's password:


Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-129-generic x86_64)
Last login: Sun Oct 29 09:38:14 2017 from 10.0.0.10
vagrant@beta-ubuntu:~$

 

Have you seen above ? system beta-ubuntu asks for password of user "vagrant". Now wish to configure system to make it like, when I login from alpha-ubuntu to beta-ubuntu without password prompt. For that purpose you must be aware of Key based login (PKI) process or at least aware about what is Public and private key. If you not aware about it, don't I ll explain it in some other post. for now we ll continue with steps to configure passwordless ssh.

  • First step is generate public and private key on alpha-ubuntu. for this we need to use ssh-keygen. you can specify algorithm to encrypt key with option "-t". Or you can leave it to default. This ll asks for file name to save public and private key. I am going with default by just pressing "Enter" button after that it will asks for passphrase. Enter passphrase or you can have nothing.  I am going with nothing so pressed "Enter" button.

         vagrant@beta-ubuntu:~$ ssh-keygen -t rsa
         Generating public/private rsa key pair.
         Enter file in which to save the key (/home/vagrant/.ssh/id_rsa):
         Enter passphrase (empty for no passphrase):
         Enter same passphrase again:
        Your identification has been saved in /home/vagrant/.ssh/id_rsa.
        Your public key has been saved in /home/vagrant/.ssh/id_rsa.pub.
        The key fingerprint is:
        d6:98:e4:9e:a3:ea:a6:de:7e:80:d4:63:56:6e:24:29 vagrant@beta-ubuntu
        The key's randomart image is:
        +--[ RSA 2048]----+
        |     .           |
        |  E o o          |
        |   o =  .        |
        |  . = oo +       |
        | . + o  S .      |
        |  . .  o .       |
        |     .  +        |
        |   .. .. .       |
        | .o==o.          |
        +-----------------+
        vagrant@beta-ubuntu:~$


  • As you seen, this generated two files "id_rsa" and "id_rsa.pub" at location "/home/vagrant/.ssh/". File " /home/vagrant/.ssh/id_rsa" contains private key for user "vagrant" and file "/home/vagrant/.ssh/id_rsa.pub" contain public key that to be sent while login to another system.
  • No we need to copy public key of vagrant user of alpha-ubuntu machine to beta-ubuntu. I am assuming that there is already "vagrant" user on beta-ubuntu machine. We can copy public key with one off ssh utility ssh-copy-id or we can go with our tradition way. I am using ssh utility.                                                                                                                             
    vagrant@alpha-ubuntu:~$ ssh-copy-id vagrant@beta_ubu
    /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
    vagrant@beta_ubu's password:

    Number of key(s) added: 1

    Now try logging into the machine, with:   "ssh 'vagrant@beta_ubu'"
    and check to make sure that only the key(s) you wanted were added.

    vagrant@alpha-ubuntu:~$
                                                                                                                                                                   
  • Now try login with "ssh 'vagrant@beta_ubu'".                                                       vagrant@alpha-ubuntu:~$ ssh 'vagrant@beta_ubu'
    Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-129-generic x86_64)

     * Documentation:  https://help.ubuntu.com/

      System information as of Sun Oct 29 10:34:37 UTC 2017

      System load:  0.25              Processes:           77
      Usage of /:   3.6% of 39.34GB   Users logged in:     0
      Memory usage: 25%               IP address for eth0: 10.0.2.15
      Swap usage:   0%                IP address for eth1: 10.0.0.11

      Graph this data and manage this system at:
        https://landscape.canonical.com/

      Get cloud support with Ubuntu Advantage Cloud Guest:
        http://www.ubuntu.com/business/services/cloud

    0 packages can be updated.
    0 updates are security updates.

    New release '16.04.3 LTS' available.
    Run 'do-release-upgrade' to upgrade to it.


    Last login: Sun Oct 29 10:33:48 2017 from 10.0.0.10
    vagrant@beta-ubuntu:~$ 
                                                                                                                                                                                                                                                                                             
  • Hueeeee You see this time beta_ubu not asked for password.
                                                                                                                                                 

Comments

Popular posts from this blog

Wheel Users in Linux

Hello, Thanks for visiting RvKmR.blogspot.in In this blog post, I am explaining about Wheel users in Linux. Red Hat release that I am working on is as below.  [ravi@localhost vagrant]$ cat /etc/redhat-release CentOS release 6.9 (Final) An Linux system can have many users like System users, normal users, and admin (root) user. Its common sens that we have is not to share root user credentials with other user, but here is case that we wish to run administrative command by normal user. In that case we need to aware about wheel users group. Let's first understand what is wheel user in Linux and why we needed it. Wheel is one of Linux user group that allow members of that group to run administrative commands those need root access of system, Wheel user facilitate to do that with sudo (superuser do ) privileges. Lets do it on terminal : Add an user and set password [root@localhost vagrant]# useradd ravi [root@localhost vagrant]# passwd rav

IT Infrastructure Monitoring

Hello, Thanks for visiting RvKmR.blogspot.in IT Infrastructure monitoring its not just words, it means a lot in the information technology world. I expect an IT professional knows what it means. In a simple word, I can say Compute, Application, and network, etc. OK, let's start why we need IT infrastructure monitoring. Monitoring IT infrastructure allows us to take preemptive action to be undertaken towards a potential problem before they affect your business. OR at least reduce time to restore your infrastructure as soon as an incident occurs. Further monitoring of IT infrastructure is divided into two categories Agent-based and agentless. An agent is a software or script installed on machines that to be monitored so that it will send information to monitoring systems. Having an agent inside the machine uses system resources, which in turn raises maintenance cost. Whereas the agentless tool is little or no impact on monitored machines as an agent is not installed on

Understanding Linux Cluster

Hello Thanks for visiting RvKmR's blogs. So, What means of clusters and why we need them. Cluster is set of servers or say computers working together to achieve single goal or a task. Now you may have idea why we need cluster.  Types of Cluster: High Availability Cluster / HA Cluster  HA Cluster again grouped in two types. Active-Active Cluster Active-Passive Cluster In Active-Active Cluster Service is running on all nodes in cluster. That means all nodes serving independently. In Active-Passive Cluster Service is running on one of node from cluster and other nodes in passive state. If primary node fails then only other node in cluster will start service.   Storage Cluster In this cluster type, all members provides a single cluster file system that can be accessed by different servers. These file system can be used to read-write data simultaneously. EX: GFS2  OK, Then what is High Availability. This type of cluster provides high availability of serv