0

I'm trying to make a batch script to log in into a SSH server and execute a few commands. The start command is:

plink -ssh [email protected]

Then I need to enter the User Name and Password like the image:

ssh

If I have the 'User Name' and 'Password' in two variables, how do I use them when it asks me for?

[EDIT]

last try was this:

(echo username
echo mypassword) | plink -ssh [email protected]

Output:

User Name:username
mypassword
Password:

The batch didn't "pressed" enter after inputing the username.

1 Answer 1

1

Try

plink -ssh -l $USER -pw $PASSWD

after setting environment variables

set USER=name
set PASSWD=secret

see http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter7.html

Sign up to request clarification or add additional context in comments.

4 Comments

I have to enter two logins and one password. In my case I am passing the first login (the SSH 'login as') before the ip (user@IP). It's like an extra login.
I don't really understand. On the server side you normally have a user account username where you want to login per ssh, so I would assume you just should plink -ssh -l $USER -pw $PASSWD ipaddress?!
Lets suppose I have to login twice. First the SSH login then the "system" login. The SSH login is fine because I only need the username (no password required). This is not about SSH, this is about auto inputing data.
I see, you have to solve it on server side then. You might want to have a look at expect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.