2

We have an SSH server that acts as an entry point to our other servers.
Once I login here via ssh, it'll prompt me to key in what server, port,
username, and password that I will be using.

Is there a way that a shell script can fill in those prompts for me?

1
  • 1
    Are you using a Wii? Please provide more information about your OS... :) Apr 3, 2012 at 8:02

2 Answers 2

1

You MUST NOT put your password in a script, use public key authentication mixed with ssh-agent-forwarding to achieve what you want, it was created to alleviate the need for a password even if you "traverse" many ssh servers.
For the cost of a mere ssh-copy-id to all the servers you will be able to connect from/to any of them.

Here is a guide to setup Agent Forwarding: http://unixwiz.net/techtips/ssh-agent-forwarding.html

edit: The part you're looking for is the one named "Public Key Access with Agent Forwarding" (sorry, no anchors in the article) but you should read the page fully because it presents all the modes of authentication supported by SSH and the last part builds on the former ones.

2
  • What part of the guide does he have to follow? Could you include the essential part in your answer? Apr 3, 2012 at 8:04
  • 1
    I think it's the one with "Public Key Access with Agent Forwarding". However, problem is, I am being prompted to fill in the access details to the next server right off the bat. How can I create ssh keys on the ssh central like that? Apr 3, 2012 at 8:20
2

As stated public key is preferable. But some institutions INSIST on username password.

For this you can use the utility expect. An example to use it with ssh is here.

Just make sure the password is properly guarded agains prying eyes ;)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .