[英]How do we run tmux from ssh agent using python
how do we create a tmux session using python based ssh client programs? 我们如何使用基于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)
It doesn't create a tmux window on checking manually from a terminal. 从终端手动检查时,它不会创建tmux窗口。
> tmux ls
no server running on /tmp/tmux-0/default
open terminal failed: not a terminal
好吧,发布脚本的tmux位,默认情况下,如果您在那里有新会话,则它将尝试附加到当前tty(不存在,因此会出现错误),例如,您需要添加-d参数以防止这种情况
tmux new-session -s username -d
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.