使用SSH而不是Python

时间:2013-04-01 14:33:48

标签: python ubuntu ssh openssh

如何在python脚本上运行此SSH?

ssh gateway@192.168.0.189 'DISPLAY=:0 notify-send "Title" "Description"'

我的python脚本将要求Title的raw_input()和Description的另一个。然后python将运行SSH,插入用户键入的TitleDescription

2 个答案:

答案 0 :(得分:2)

import subprocess
subprocess.check_call(
    '''ssh gateway@192.168.0.189 'DISPLAY=:0 notify-send "{0}" "{1}"' '''.format(title, description),
    shell=True)

答案 1 :(得分:1)

如果您想要更多控制,还应该查看paramiko库:https://github.com/paramiko/paramiko这是一个用于python的SSH2库。