【问题标题】:How do we run tmux from ssh agent using python我们如何使用 python 从 ssh 代理运行 tmux
【发布时间】: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


    【解决方案1】:

    open terminal failed: not a terminal

    好的,发布脚本的 tmux 位,默认情况下,如果您有一个新会话,它将尝试附加到当前 tty(因此错误),例如您需要添加一个 -d 参数来防止这种情况

    tmux new-session -s username -d

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-14
      • 1970-01-01
      • 2019-05-22
      • 2014-10-05
      • 1970-01-01
      • 2018-08-26
      • 2021-02-22
      相关资源
      最近更新 更多