【发布时间】:2020-01-15 04:11:02
【问题描述】:
我们如何使用基于 python 的 ssh 客户端程序创建 tmux 会话?
from pssh.clients import ParallelSSHClient
def Estabish_Connection(host,username,passkey):
client = ParallelSSHClient([str(host)],user=str(username), password=str(passkey))
return client
client2 = Estabish_Connection('host','root','password')
cmd_out = client2.run_command('tmux new -s myname')
for host,out in cmd_out.items():
for line in out.stdout:
print(line)
它不会在从终端手动检查时创建 tmux 窗口。
> tmux ls
no server running on /tmp/tmux-0/default
【问题讨论】:
标签: python linux shell ubuntu ssh