Monday, October 8, 2012

Setup Passwordless SSH between two servers in LINUX


SSH or Secure Shell is a network protocol that allows data to be exchanged using a secure channel between two networked devices.

The encryption used by SSH provides confidentiality and integrity of data over an insecure network, such as the Internet.

SSH was designed as a replacement for Telnet/rlogin/rsh and other insecure remote shells, which send information, notably passwords, in plaintext, leaving them open for interception.

Setup SSH Configuration:

Step #1: Hostnames are HYD01 and HYD02

Step #2: Generating Identity key pair on HYD01,

a) Create a directory .SSH under /home/oracle

$ mkdir .ssh

b)Give permissions to .ssh

$ chmod 755 .ssh

c) Generate RSA key pair

$ /usr/bin/ssh-keygen -t rsa

d) Generate DSA key pair

$ /usr/bin/ssh-keygen -t dsa

$ cd .ssh

$ ls

id_dsa id_dsa.pub id_rsa id_rsa.pub

Step #3: Add rsa and dsa keys to HYD01

cat id_dsa.pub > HYD01
cat id_rsa.pub >> HYD01

Now same steps follow on Host HYD02.

Step #4: Generating Identity key pair on HYD02,

a) Create a directory .SSH under /home/oracle

$ mkdir .ssh

b)Give permissions to .ssh

$ chmod 755 .ssh

c) Generate RSA key pair

$ /usr/bin/ssh-keygen -t rsa

d) Generate DSA key pair

$ /usr/bin/ssh-keygen -t dsa

$ cd .ssh

$ ls

id_dsa id_dsa.pub id_rsa id_rsa.pub

Step #5: Add rsa and dsa keys to HYD02

cat id_dsa.pub > HYD02
cat id_rsa.pub >> HYD02

Step #6: Copy public keys from host HYD01 to HYD02

scp HYD01 oracle@HYD02:/home/oracle/.ssh

Step #7: Add HYD01 and HYD02 public keys to authorised_keys

cat HYD01 > authorized_keys
cat HYD02 >> authorized_keys

Give permissions to authorized_keys

$chmod 644 authorized_keys

step #8: Copy authorized_keys from HYD02 to HYD01

scp authorized_keys oracle@HYD01:/home/oracle/.ssh

In Hyd01 also give permissions for authorized_keys

$chmod 644 authorized_keys

Now you can copy/move files from HYD02 to HYD01 and vice versa without password.


No comments:

Post a Comment

Some Most Popular Articles