Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Are you using a Wii? Please provide more information about your OS... :) – Tom Wijsman Apr 3 '12 at 8:02
up vote 1 down vote accepted

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:

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.

share|improve this answer
What part of the guide does he have to follow? Could you include the essential part in your answer? – Tom Wijsman Apr 3 '12 at 8:04
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? – cr8ivecodesmith Apr 3 '12 at 8:20

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 ;)

share|improve this answer

You must log in to answer this question.

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