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

Possible Duplicate:
How do I set up SSH so I don't have to type my password?

I'm trying to write a shell script to connect my MBP to my server (for tunneling) every-time it boots. I'm having problem with the password prompt, can you advise?

I found this script online (modified), but spawn and send don't seem to exist?

echo "Logging in and creating local proxy"
spawn ssh -2 -R 7654:localhost:7654 -A -D 1080
match_max 100000
# Look for password prompt
expect "*?assword:*"
# Send password
send -- "PASSWORD\r"
# send blank line (\r) to make sure we get back to gui
send -- "\r"
expect eof
echo "All done"

Anyone else know how to do this properly?

share|improve this question

marked as duplicate by Nifle, BinaryMisfit Oct 13 '10 at 8:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 5 down vote accepted

This script is solving the problem of the login by giving the pass and login. It is dangereous to write that in a file in any case. You should better configure your ssh in a way to avoid to give your login pass, you can for example used your ssh keys for that. Generate your keys on your workstation, ssh-keygen, it will create the keys in ~/.ssh/ the public key is Then in the root account of add your public key to ~/.ssh/authorized_keys.

share|improve this answer

You should set-up passwordless ssh logins with ssh-agent. See this question for a how-to.

share|improve this answer
perfect answer. – Louis Oct 12 '10 at 17:10

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