Web Hosting Talk







View Full Version : Running SSH autonamously


hgkevin
06-10-2005, 10:31 AM
I'd like to have a script run an an ssh connection automatically from a unix based machine.

However, I cannot find how I can enter my password to the ssh script through a script:

-bash-2.05b$ ssh user@host
user@host's password:

I've tried having it read from a file:
ssh user@host < filewithpw

however, this does not seem to work.

Any ideas?

Thanks.

snokrash257
06-10-2005, 11:52 AM
If you use public key authentication, using shosts, or rhosts, you won't need to enter a password.
man ssh tells a little on how to set this up with or without RSA

TimSG
06-10-2005, 04:04 PM
I can not urge strongly enough using public key authentication! MUCH safer and easier than passwords!

gogocode
06-10-2005, 10:56 PM
To setup public key auth you can use the ssh-copy-id script

bash$ ssh-copy-id user@host

then you should be able to do

bash$ ssh user@host

and not need to give a password

(of course, depends on if the remote server allows pub key auth)

I've attached the script incase you don't have it installed

xorion
06-11-2005, 06:52 AM
Originally posted by hgkevin
I'd like to have a script run an an ssh connection automatically from a unix based machine.

However, I cannot find how I can enter my password to the ssh script through a script:

-bash-2.05b$ ssh user@host
user@host's password:

I've tried having it read from a file:
ssh user@host < filewithpw

however, this does not seem to work.

Any ideas?

Thanks.

be careful, as it is a security issue,
remeber to have encryption of passwd etc
with PKI or secret key