Hi.
Does anyone know of a way to run a script that'll auto connect to a server via SSH (smoothwall), login and then perform a few commands, then close the SSH session.
Thanks in advance all. :).
Printable View
Hi.
Does anyone know of a way to run a script that'll auto connect to a server via SSH (smoothwall), login and then perform a few commands, then close the SSH session.
Thanks in advance all. :).
First off, you need to swap ssh keys with the remote system so you can login without a password prompt.
HOWTO: set up ssh keys
At that point you can either run a single SSH command to run the script on the remote system.
Or run the commands over SSH one after the other.Code:ssh user@system /usr/bin/somescript.sh
Code:ssh user@system /usr/games/fortune | /sbin/wall
ssh user@system /sbin/reboot
If you mean from Windows to the Linux machine, I'd just do it with PLink the command line driven aspect of Putty...
Using the command-line connection tool Plink
Should do everything quite happily.
As pointed out above, on Windows plink connecting with a key file should do it. I've actually had occasion to write a utility that does pretty much what you describe above, for which I used Python:
Code:for fileLine in os.popen("PuTTY\\plink -batch -i PuTTY\\xenConsole.ppk root@" + dirName + " cat /proc/mdstat").readlines():
line = fileLine[:-1]
reResult = re.search(" *(.*) blocks \[(.*)/(.*)\] \[(.*)\]", line)
if reResult:
RAIDState = reResult.group(4)
The above connects to the server and gets the state of the mdadm RAID array, sorting through the answer with a regular expression to parse out the data needed.
--
David Hicks
Thanks for the answers folks... now I am wondering what the OP was wanting and how we might officially support what he's after? ;)