Killercode
Killercode

Reputation: 904

SSH Shell Script

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?

Upvotes: 0

Views: 410

Answers (2)

dschulz
dschulz

Reputation: 4786

ssh-keygen -t rsa -b 4096
ssh-copy-id [email protected]
ssh [email protected] 'ls -la ~ ; pwd ; uname -a '

Upvotes: 0

Trevor
Trevor

Reputation: 60000

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"

Upvotes: 1

Related Questions