Operating System - HP-UX
1833464 Members
2525 Online
110052 Solutions
New Discussion

Re: SFTP without password in scripts

 
Arunananth
Occasional Advisor

SFTP without password in scripts

There are two servers.

1. SSH server
2. Client Server

I need to run the script from ssh server to client server using sftp.

Problem:
When i run the scripts its asking password.

ssh01# ./do_cfg
Connecting to client01...
Password:

content of do_cfg script:

#!/bin/sh
#


HOSTNAME=`hostname`
cp -p /usr/local/bin/.netrc $HOME
cd /usr/local/data/
sftp client01 <cd /depot/
put *gz
EOF
rm $HOME/.netrc

content of .netrc:
ssh01# more .netrc
machine client01 login root password *******

Without asking password i need to run the script

Kindly suggest me how to proceed further.
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor

Re: SFTP without password in scripts

Ganesan R
Honored Contributor

Re: SFTP without password in scripts

Hi,

You need to setup password less login before run the script.

- logon to serverA as user doing transfer
- ssh-keygen -t dsa
- cat ~/.ssh/id_dsa.pub (copy contents)
- logon to serverB as user doing transfer
- cd ~/.ssh
- vi authorized_keys (paste contents from key above)

Make sure the following permissions are set in destination server(Server B in your case)

Home directory should have 755 permission (users home directory)
$HOME/.ssh directory should have 700 permission
$HOME/.ssh/authorized_keys file should have 600 permission

Refer this thread as well..
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1310366
Best wishes,

Ganesh.