How to automate SSH remote connection with a shell script

Hi Guys!

I am trying to write a shell script for automated ssh. vairable user and passwd have initialized correctly, but when I use the following it still prompting me for the password.

#!/usr/bin/bash

user='root@10.14.76.225'
passwd='admin'

ssh $user
$passwd
uptime
exit

I have also tried the following

ssh $user < $passwd
uptime
exit
EOF

and no luck. Please help. Thanks in advance.

Br,
pinpe

google it "password less ssh"

Best way to automate ssh connection is making trusted relantionships between the machines. Search google for authorized_keys :slight_smile:

Hello!

Per forum rules, and the benefit of all users, please search the forums before posting a question.

You can easily search the forums using our internal Google search engine or our advanced internal search engine. You can also search our huge UNIX and Linux database by user generated tags or search the database for unanswered questions and provide an answer.

Thank you.

The UNIX and Linux Forums