0

I am trying to do a shell script that can connect to a remote machine via ssh

then problem is that I can relly on keys and stuff like that. I just want to add the hostname, user and pass and execute some commands... can someone guide me on that path?

1
  • 1
    Why do you suppose a product (and for some, a way of life) that is named Secure shell (ssh), would allow you to say, 'Oh, nevermind about the security part' ;-)? You either have to submit a password when you start the program, OR have key files set up on your remote machines OR use expect. Sorry, that's the way it is. Good luck. Commented Aug 3, 2011 at 18:58

2 Answers 2

1

Look into expect for linux.

The script would look something like this:

#!/usr/bin/expect
spawn ssh root@IPADDRESS /script/on/remote/machine
expect "*?assword:*"
send -- "PASSWORDHERE\r"
Sign up to request clarification or add additional context in comments.

2 Comments

I would really like to avoid expect
I don't want to have to install 3rd party
0
ssh-keygen -t rsa -b 4096
ssh-copy-id [email protected]
ssh [email protected] 'ls -la ~ ; pwd ; uname -a '

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.