1748180 Members
3772 Online
108759 Solutions
New Discussion юеВ

Re: automating sftp

 
SOLVED
Go to solution
so.nimda
Super Advisor

automating sftp

Hi,

I need some help in automating sftp.

I have searched this forum and there are numerous threads on this topic but it pertains to OpenVMS.

I am running HP-UX 11.23.

I have tried putting the password in a batch file and executing sftp with '-b' option but it doesn't seem to work - it always prompts for password. =(

Does anyone know how to make it work?

Thanks in advance
7 REPLIES 7
G V R Shankar
Valued Contributor
Solution

Re: automating sftp

I am not sure about sftp, I know you can automate using scp. Following is the procedure.

On source server, generate public and private keys.

/usr/bin/ssh-keygen -t rsa
/usr/bin/ssh-agent $SHELL
/usr/bin/ssh-add

Just keep hitting return key.

On the Destnation Server

mkdir $HOME/.ssh
chmod 700 $HOME/.ssh

From Source Server to Dest

scp $HOME/.ssh/id_rsa.pub Dest_Server_IP:$HOME/.ssh/id_rsa.pub_Source_Server

On Dest Server

cat $HOME/.ssh/id_rsa.pub_Source_Server >> $HOME/.ssh/authorized_keys

You are done.

Cheers,
Ravi.
G V R Shankar
Valued Contributor

Re: automating sftp

Hi,

After following the above procedure, I just found that sftp hostname is not asking any password.

Ravi.
Steven Schweda
Honored Contributor

Re: automating sftp

> [...] it always prompts for password. =(

Have you arranged the key files for SSH
access without a password? (Why not?)

Normally, SSH, SCP, SFTP, Sxxx are used when
one does not wish to specify a password
interactively. (And there should be any
number of Forum threads related to setting up
SSH access without using a password, for
practically every OS.)
Suraj K Sankari
Honored Contributor

Re: automating sftp

Hi,

If you configure your server SSH without passwd it will automaticly configure for all S* like SSH, SCP, SFTP, so just configre the above things and do sftp without passwd.

Suraj
so.nimda
Super Advisor

Re: automating sftp

Hi all,

Thanks for all your replies.

With regards to setting SSH access without password, is it an "all or nothing" setting? In other words, is it a global setting in that once set without password, all access will be without password or can it be set such that some users will not be prompted while some will?

Regards
Steven Schweda
Honored Contributor

Re: automating sftp

> [...] is it an "all or nothing" setting?

It can be done per host ("hostbased") or per
user ("publickey"). Find some appropriate
SSH documentation. As I suggested before, a
Forum search should lead to some. (I could
do it for you, but you'll learn more this
way.)
Dennis Handly
Acclaimed Contributor

Re: automating sftp

>is it an "all or nothing" setting? In other words, is it a global setting in that once set without password, all access will be without password or can it be set such that some users will not be prompted while some will?

Each user can set it as he pleases. Assuming you mean from UserA to UserA on different machines.
You can also set it up so a user doesn't have to enter a passphrase at all (a generic account), to being required at least once.
There may be configuration settings that may disallow some of these?