I’m new to shell scripts, and I have centos running. I want to write a shell script that ssh a remote machine and execute a bunch of commands. The problem I’m facing is how to provide the username, the password, the remote machine address, and the private access key to a command that shall connect the remote machine.
I’ve Google’d and found some scripts, but all of them need a utility called expect, and I don’t want to install any utility, only to run my script. Is there a way to do this?
You can pass all you need in a
sshcall, doing the following:If you’re going to use this connection many times, and want to maintain it configured, add the following lines to you
.ssh/configfile:and then access the remote machine, and execute the command you want, by doing:
Notice that command, AFAIK, must be embraced in quotes, as it must be considered as only one argument by
ssh.