我正在尝试编写一个脚本,该脚本将ssh放入框中。我使用Python并利用paramiko库。我可以在该框上成功ssh,但只要脚本终止,ssh连接也会终止。脚本完成运行后,我想保持连接打开。Python ssh - 在脚本终止后保持连接打开
的Python:
self.ssh = paramiko.SSHClient()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.ssh.connect(host, username=self.username, password=self.password)
stdout = execute(self.ssh, 'pwd') # test command for now to verify i'm on box
print stdout
sys.exit()
控制台:
$ ssh.py
[U '/家/ myuser的\ n']
为myuser @ XXXX〜
$
我一直没能在网上找到类似的例子,所以任何帮助,将不胜感激。
要终止我的脚本 –
你要什么的连接做脚本终止后? –
我希望连接在shell中保持打开状态 –