Operating System - HP-UX
1820636 Members
1850 Online
109626 Solutions
New Discussion юеВ

non-interactive transfer of a file using SFTP

 
SOLVED
Go to solution
Gangadhar_1
Occasional Advisor

non-interactive transfer of a file using SFTP

Hi all,
Please help me in transfering a file using SFTP non-interactively. I am already using expect script for that but its not working when i keep it in crontab file. (refere my previous thread)

I also tried keeping the keys in destination machine, but coudln't get the ultimate result.

Thanks in advance.
5 REPLIES 5
KapilRaj
Honored Contributor

Re: non-interactive transfer of a file using SFTP

I never tried ssh-keygen with sftp. But an scp works so you may use it.
Nothing is impossible
Gangadhar_1
Occasional Advisor

Re: non-interactive transfer of a file using SFTP

@Kapil Raj
Thanks for your reply Kapil Raj.

Actually i have tried it already, but then also its giving the error, "No principal in keytab matches desired name", and it is again asking for the password.

If you could brief me the exact procedure to authenticate using this ssh-keygen, it'll be very helpfull for me. (coz i think i'm goin wrong somewhere here only..)

Thanks a lot.
Peter Nikitka
Honored Contributor
Solution

Re: non-interactive transfer of a file using SFTP

Hi,

the exact procedure is found in ther man pages of ssh and ssh-keygen.

Short:
For user_from@host_from:
1) ssh-keygen -t rsa
2) cd ~/.ssh

For 3+4 you need the password:
3) scp id_rsa.pub user_to@host_to:ssh/key-user_from
4) ssh user_to@host_to

Now you are user_to at host_to.
Create keys as well, if not already existing here, because in short or long terms you will need them :-) .
5) ssh-keygen -t rsa
5) cd .ssh
6) cat key-user_from >>authorized_keys
7) chmod 600 authorized_keys
8) exit

Now you are user_from at host_from again.
This should work without the request of a password:
9) ssh user_to@host_to date


There may be many things, which cause the failure of this setup. For details read the man pages, for tracing use
ssh -vvv user_to@host_to date


mfG Peter

The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Peter Nikitka
Honored Contributor

Re: non-interactive transfer of a file using SFTP

Hi,

did you make progress in your efforts? It is good practise in this forum to post results of the suggestions.

mfG Peter

The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Gangadhar_1
Occasional Advisor

Re: non-interactive transfer of a file using SFTP

@Peter

sorry peter, these two days were weekends, so coudln't reply..

and i tried using that procedure, but still its asking for password.. but somehow one of my colleague did it.. and its working only for his login, he also is unable to set it up to other login.. i donno whats goin wrong but anyways, i got to know about many things by this discussions..

thanks to one and all, involved in this discussion..

Kind regards,
Gangadhar