Connect to one server from other server without asking password

Hi ,
I am using redhat linux 5.I.I need a command or script which need to login from one server to another without asking password.This can be done even providing password on the command line is also fine.I have tries sshpass but it didn't work.ssh key generations is not preferred here.

please help me on this if it can be done in any other way.

In what way did sshpass "not work"?

expect can drive in the ssh password, or scripts like it that capture the ssh tty to stdin. There are many other sorts of servers you can set up to do specific tasks, like https web. There may be ways to do the remote tasks locally (nfs) or more indpendently (cron). The normal solution is ssh trust using PPK. Who says that is bad? Scripting a password is pretty universally considered worse!

Thanks for your replies.Finally i am able to connect to the destination server wihtout asking password by below command.

sshpass -p 'password' ssh -o StrictHostKeyChecking=no root@serverip.

but now i want to execute a command as below and i want to pass this one as a parameter to the command above.could u pls help on this.

isi_for_array -s "isi auth ads time --sync --force"

so this isi command i want to provide the input to the sshpass command.how can i do that?

Append the command, eg:

sshpass -p pass123 ssh -o StrictHostKeyChecking=no root@1.1.1.1 "echo 123"

--ahamed

Hi thanks for your reply.I tried that option but this time it is not even connected to the destination server with below approach.It is able to login with normal sshpass command.My whole purpose here is source is a server and destiantion is storage.I want to run a cron on server which connect to the storage and runs the command mentioned in the post below.

output of the command here isicommand as a parameter is:

[sanadmin@server1 ~]$ sshpass -p 'password' ssh -o StrictHostKeyChecking=no root@storageip "echo isi_for_array -s "isi auth ads time --sync --force""
isi_for_array -s isi auth ads time --sync --force
[sanadmin@server1 ~]$

I am not sure whether command was successful or not.But it appears to me it not.

You should not echo it, what i gave was an example.Try this...

sshpass -p 'password' ssh -o StrictHostKeyChecking=no root@storageip 'isi_for_array -s \"isi auth ads time --sync --force\" '

--ahamed

1 Like

Thanks a lot for your reply.Command executed fine and i am able to run the command through crontab as well.cheers:b: