19.01.2016, 10:00
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