Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 root@server.com
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, Diago 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.

2 Answers 2

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 id_rsa.pub. Then in the root account of server.com 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 or ask your own question.