Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在ssh会话中启用tty_Python_Scripting_Ssh_Tty - Fatal编程技术网

Python 在ssh会话中启用tty

Python 在ssh会话中启用tty,python,scripting,ssh,tty,Python,Scripting,Ssh,Tty,我想在一个脚本中加入一些登录信息,供许多用户使用。在python中,我将input_raw设置为从dev/tty读取,但是当我通过ssh连接到服务器上运行的脚本时,它会失败得很厉害 想法?变通办法 我宁愿避免在脚本中硬编码用户名 请并感谢您。尝试使用-t选项进行ssh: -t Force pseudo-tty allocation. This can be used to execute arbi- trary screen-based programs o

我想在一个脚本中加入一些登录信息,供许多用户使用。在python中,我将input_raw设置为从dev/tty读取,但是当我通过ssh连接到服务器上运行的脚本时,它会失败得很厉害

想法?变通办法

我宁愿避免在脚本中硬编码用户名


请并感谢您。

尝试使用
-t
选项进行ssh:

-t Force pseudo-tty allocation. This can be used to execute arbi- trary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.
将其另存为
ssh-t
或类似的东西,
chmod+xsh-t
,并将其放在
路径中的某个位置。然后设置
GIT\u SSH=SSH-t
告诉GIT使用这个脚本。

这可能会起作用,但我正在通过GIT推送启动SSH连接。有没有办法注入-t选项?@garbagecollector:环境变量告诉Git ssh使用哪个命令。正如该页上所解释的,要将选项传递给ssh,您可以将其包装在另一个shell脚本中,或者使用
~/.ssh/config
(我建议使用后者)。@garbagecollector:根据,似乎没有一个与-t等效的配置选项。我将创建一个shell脚本(请参见编辑后的答案)。您可能希望使用“$@”而不是“$*”,这样ssh-t的单独参数就不会被分组到ssh的一个参数中。
#!/bin/sh

ssh -t "$*"