General
cancel
Showing results for 
Search instead for 
Did you mean: 

how to provide password in case of batch files(ssh protocol)

ManojKumar
Advisor

how to provide password in case of batch files(ssh protocol)

Hi all,

I m new to this forum .
Need to know the procedure to provide the password in case of batch files , also i m working on ssh protocol .
What i m trying is given below::

IF "%1"=="" GOTO :END
SET PASSWD=%1
CALL otherbat
:END
REM maybe echo a warning that everything else will not work properly
REM because of a missing password

OTHERBAT.BAT

echo %PASSWD%| ssh root@
OR
echo "PASSWD">ssh IP -l root

Problem:: It is not accepting the password, everytime i m supposed to enter the same manually .

regards,
manoj
11 REPLIES
Yogeeraj_1
Honored Contributor

Re: how to provide password in case of batch files(ssh protocol)

hi manoj,

have a look at this thread:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=190528


hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
ManojKumar
Advisor

Re: how to provide password in case of batch files(ssh protocol)

Hi,

actually i don't want to disable the password prompt .
Also, i want to use the same in windows .

Need to know the procedure to provide the password .

regards,
manoj
Jean-Yves Picard
Trusted Contributor

Re: how to provide password in case of batch files(ssh protocol)

Hello,

((insert lecture about hard coded password here))

I couldn't tell if you start you client from Unix or DOS.

I haven't seen any way to send password from Unix.

however if you are using putty,
there is a -pw option which might help you.

Jean-Yves Picard
Michael Selvesteen_2
Trusted Contributor

Re: how to provide password in case of batch files(ssh protocol)

Hi,

Like FTP, SSH will not accept password from a batch file. My suggestion is to set up public key authentication between those machines. Else if security of your password is not a concern for you, then an expect script can automate your ssh login.

A simple search in this forum about public key authentication will result in number of threads explaining how to set up public authentication.

Also you can try man ssh, scp and sftp
ManojKumar
Advisor

Re: how to provide password in case of batch files(ssh protocol)

Hi,

It' really nice to hear from u guys-- .

Actually i don't want to use any tool like putty, cygwin, SSHSecureShellClient-3.2.9b283 etc.. .

I just want to execute one simple command using windows platform-
i.e. ssh -T root@
and want to provide the password through my program .

Presently i m using batch files .Need to know the procedure / hint --how to provide the password .

regards,
manoj
paolo barila
Valued Contributor

Re: how to provide password in case of batch files(ssh protocol)

Sorry, how come you have ssh on windows if you didn't install a ssh client?
share share share
ManojKumar
Advisor

Re: how to provide password in case of batch files(ssh protocol)

Hi Paolo,

Actually i m using OpenSsh . I have pasted the dll' and ssh.exe in the system32 folder of Windows .

Now, i can run the ssh.exe from any directory .

regards,
manoj

paolo barila
Valued Contributor

Re: how to provide password in case of batch files(ssh protocol)

Hi,
I would install a ssh client and configure a publickey authentication:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=999102
share share share
ManojKumar
Advisor

Re: how to provide password in case of batch files(ssh protocol)

Hi,

It' nice to see yr quick replies .

I need a mechanism to provide the password .
Public key authentication is basically for password-less-login (as per my knowledge).

I am using windows platform and i want to execute a single ssh command, also i want to provide the password through my program .

That' all from my side---


regards,
manoj
paolo barila
Valued Contributor

Re: how to provide password in case of batch files(ssh protocol)

so, as Michael Selvesteen said,
I think you should use expect
http://expect.nist.gov
share share share
rmueller58
Valued Contributor

Re: how to provide password in case of batch files(ssh protocol)

Expect is a very nice way to create interaction with the shell for automation


I would use expect to handle the issue.
In the script below I am using scp to scp a file from one server to another.

#!/usr/local/bin/expect
spawn /usr/local/bin/scp -v /tmp/*apphire.txt user@IPADDRESS:/tmp
expect "user@IPADDRESS's password:"
send "password\r"
expect "debug: uninitializing event loop"
send "\r"


For your case

#!/usr/local/bin/expect
spawn ssh root@IPADDRESS
expect "user@IPADDRESS's password:"
send "password\r"
expect "Authentication successful."
send "\r"

Download expect and give it a try,