06.01.2016, 07:52
First you need to generate your private key and extract public key from that, create a script and run it once:
In logs you will see a line like "ssh-rsa AAAAB3Nz...", you have to copy it to authorized_keys (or authorized_keys2) file on your HTPC.
Then you can run any command via SSH which does not require user input:
Code:
key = '/lib/genohm-scada/mnt/storage/id_rsa'
os.execute('dropbearkey -t rsa -f ' .. key)
keyinfo = io.readproc('dropbearkey -y -f ' .. key)
log(keyinfo)
In logs you will see a line like "ssh-rsa AAAAB3Nz...", you have to copy it to authorized_keys (or authorized_keys2) file on your HTPC.
Then you can run any command via SSH which does not require user input:
Code:
key = '/lib/genohm-scada/mnt/storage/id_rsa'
user = 'root'
ip = '192.168.1.100'
port = 22
cmd = 'ls'
run = string.format('ssh -y -i %s %s@%s/%d %q', key, user, ip, port, cmd)
result = io.readproc(run)
log(result)