Operating System - HP-UX
1752795 Members
6130 Online
108789 Solutions
New Discussion юеВ

Use scp and to exit if password prompted

 
SOLVED
Go to solution
Ajay Saini
Frequent Advisor

Use scp and to exit if password prompted

Hello,

In a HPUX shell script, we are doing scp to a node....

But sometimes it asks for password for some servers..... What I need is that if on scp password is prompted then to exit the scp and if no password prompted then do the required steps....

Please to provide any help

Regards;
Ajay Saini
6 REPLIES 6
Kees C
Visitor
Solution

Re: Use scp and to exit if password prompted

scp -o BatchMode=yes ......
James R. Ferguson
Acclaimed Contributor

Re: Use scp and to exit if password prompted

Hi Ajay:

> But sometimes it asks for password for some servers.

Then, fix the fundamental problem if this isn't the desired behavior. Make sure that you have setup public ssh keys for the node(s) in question.

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: Use scp and to exit if password prompted

http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1482739

If you want to use only public-key
authentication, then you might try adding
something like the following to your scp
command:

-o AllowedAuthentications=publickey
Joseph Steinhauser
New Member

Re: Use scp and to exit if password prompted

Ajay,

When calling scp, use the option/qualifier of

-o BatchMode=yes

This will tell scp (or any ssh-family tool) that it should not prompt the end user for a password. (as if being run by script, or cron job)

With BatchMode turned on, if scp cannot connect with the keys in $HOME/.ssh/ dir, then it will show you a message on stdout, and the script will keep moving, rather than stop/prompt, so you never see the "Password:" message.

Read this, and many other useful options in the general "ssh" man-page, or see details in "man 5 config"

Joseph.

HPUX web-man-pages are confused this week,
you might try:
http://unixhelp.ed.ac.uk/CGI/man-cgi?ssh+1
http://unixhelp.ed.ac.uk/CGI/man-cgi?config+5
Old School efficiency. New World Tools.
Ajay Saini
Frequent Advisor

Re: Use scp and to exit if password prompted

Thanks .... everybody for the help
It resolved the issue

Regards;
Ajay Saini
rmueller58
Valued Contributor

Re: Use scp and to exit if password prompted

I use scp -B after doing the ssh key exchange.