mrbear 发表于 2015-12-15 11:36:55

python -Fabric sudo: sorry, you must have a tty to run sudo

用fabric部署文件到远程服务器时,遇到sudo: sorry, you must have a tty to run sudo 这个错误。
如果从远程服务器端处理很容易,打开tty即可,但是既然ssh 有-t ,允许 Pseudo-tty Allocation ,那么 Paramiko 难道就没有? 后来一查,果然有啊,

stdin,stdout,stderr=ssh.exec_command(cp_war_cmd)

改成如下形式,即加上 get_pty =True即可。
stdin,stdout,stderr=ssh.exec_command(cp_war_cmd, get_pty=True)
页: [1]
查看完整版本: python -Fabric sudo: sorry, you must have a tty to run sudo