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
#5
First you need to generate your private key and extract public key from that, create a script and run it once:
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)
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 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: