This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

ssh to shut down a remote pc
#6
Thanks! here are two user functions anyone can copy/paste to reuse the above code

Code:
--Functions to run ssh on the LM

--Run a ssh command on a remote system
function sshcommand(user, ip, port, cmd)
 key = '/lib/genohm-scada/mnt/storage/id_rsa'
 run = string.format('ssh -y -i %s %s@%s/%d %q', key, user, ip, port, cmd)
 result = io.readproc(run)
 log(result)
end

--Run once to create key
--copy into the file authorized_keys on system to be logged in
function sshcreatekey()
 key = '/lib/genohm-scada/mnt/storage/id_rsa'
 os.execute('dropbearkey -t rsa -f ' .. key)
 keyinfo = io.readproc('dropbearkey -y -f ' .. key)
 log(keyinfo)
end
Reply


Messages In This Thread
RE: ssh to shut down a remote pc - by admin - 05.01.2016, 07:37
RE: ssh to shut down a remote pc - by admin - 06.01.2016, 07:52
RE: ssh to shut down a remote pc - by managementboy - 19.01.2016, 10:00
RE: ssh to shut down a remote pc - by baggins - 29.10.2016, 10:40
RE: ssh to shut down a remote pc - by baggins - 30.10.2016, 20:31
RE: ssh to shut down a remote pc - by Igor - 25.06.2020, 09:41
RE: ssh to shut down a remote pc - by admin - 25.06.2020, 11:07

Forum Jump: