1

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?

2 Answers2

5

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.

Louis
  • 2,770
2

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