remote command execute telnet with 1 command
How I can make a script that connects to a remote computer via telnet and executes a single command (reboot).
The reason that I want to do that is because I want to make a simple script that pings some host and if it is down the linux box will connect via telnet to gateway and reboots it.
Create a script with expect that will be invoked from a shell script if ping fails:
WARNING! The username/password combination can be viewed by anyone who reads the script! I use sudo because reboot requires root access, and don't even think about putting the root in a script.
If security is an issue, use ssh with a public key setup. Then you could do a remote reboot by running:
$ ssh firstname.lastname@example.org /sbin/reboot
$ ssh email@example.com sudo /sbin/reboot
Or even add one of these to your .bashrc file to make it really easy:
alias remote_reboot='ssh firstname.lastname@example.org /sbin/reboot'
alias remote_reboot='ssh email@example.com sudo /sbin/reboot'
There should be heaps of info about setting up sshd properly here, or through Google.
|All times are GMT -5. The time now is 07:56 AM.|