how do we create a tmux session using python based ssh client programs?
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 ls
no server running on /tmp/tmux-0/default
open terminal failed: not a terminal
好吧,发布脚本的tmux位,默认情况下,如果您在那里有新会话,则它将尝试附加到当前tty(不存在,因此会出现错误),例如,您需要添加-d参数以防止这种情况
tmux new-session -s username -d
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.