There are two types of authentications that are being used in UNIX systems for SSH connections. The first one is in password-based authentication and the second one is in public key-based authentication. In public key-based authentication, we used a key pair for SSH convection and there is no password required in this method.
HP-UX SSH Login Without Password
Here I have two servers server1 and server2 and I am going to set up passwordless authentication between these two.
- Create the key pair on the first server i.e. server1, it will create /home/dbappwb/.ssh/id_rsa as a private key and /home/dbappwb/.ssh/id_rsa.pub as a public key. These keys will be created inside your home directory in the .ssh directory.
$ ssh-keygen -t rsa Generating public/private rsa key pair. Please be patient.... Key generation may take a few minutes Enter file in which to save the key (/home/dbappwb/.ssh/id_rsa): Created directory '/home/dbappwb/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/dbappwb/.ssh/id_rsa. Your public key has been saved in /home/dbappwb/.ssh/id_rsa.pub. The key fingerprint is: 3f:87:a5:ff:7d:18:ed:28:ef:97:ce:36:31:9e:e1:fd dbappwb@server1 The key's randomart image is: +--[ RSA 2048]----+ | | | | | | | | | S . . | | . + .+.| | = . o=B| | +. +O=| | .=*+E| +-----------------+ $
- If the .ssh directory is not available on server2 then you have to create the same before copying the public key.
$ ssh dbappwb@server2 mkdir -p .ssh The authenticity of host 'server2 (server2)' can't be established. ECDSA key fingerprint is 47:d3:6a:74:3f:32:f4:bb:38:e1:0b:f0:77:3d:44:0b. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'server2' (ECDSA) to the list of known hosts. Password: $
- Install the public key in server2, using the command shown below.
$ cat $HOME/.ssh/id_rsa.pub | ssh dbappwb@server2 'cat >> $HOME/.ssh/authorized_keys' Password:
- Now you may connect to server2 from server1 through SSH and it will not ask for any password.
$ ssh dbappweb@server2 $
Last Updated: August 30, 2020