Monday, 22 January 2018

Moving Files across Linux Servers without prompting for passwords

Transfer Files between 2 Linux Machine without prompt for the Password

Server A [192.168.1.20]
Server B [192.168.1.21]

You want to automate it that shell script run at any time and move file from Server A to Server B with out prompting for the passwords.

-- Ping Server B from Server A and and Server A from Server B.

ping -t 192.168.1.21
64 bytes from 192.168.1.21 icmp_seq=1 ttl=64 time=0.246

Let suppose that Oracle user should be used to transfer files a folder in Server A to Server B

Login through Oracle User to Server A and run from below command :

Oracle] $  ssh-keygen -t rsa
Just press enter

It will generate 2 files in /home/oracle/.ssh directory:
id_rsa.pub
id_rsa

-- File id_rsa.pub are your public keys copy this file to Server B to location /home/oracle/.ssh

.ssh] $scp id_rsa.pub oracle@192.168.1.21:/home/oracle/.ssh
password: *********

--Now Goto Server 2

oracle] $ cd .ssh
.ssh] $ cat id_rsa.pub >>~/.ssh/authorized_keys

It will be appended to authorized keys file.

chmod 600 authorized_keys  &

chmod -R 700 .ssh/


--Now move any file from Server A to Server B with prompting for passwords

scp any_directory/anyfiles oracle@serverB:/anydiretory


File will be copied without prompting for password.


No comments:

Post a Comment

Installing Oracle 11g on Linux

Unpack Files Unzip the files. # 11.2.0.1 unzip linux.x64_11gR2_database_1of2.zip unzip linux.x64_11gR2_database_2of2.zip #11.2.0.2 u...