在ssh会话中启用tty

myu*_*uf3 4 python ssh scripting tty

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

思考?解决方法?

我宁愿避免将用户名硬编码到脚本中.

谢谢,麻烦您了.

Gre*_*ill 5

尝试使用-tssh选项:

     -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/config,因此您需要创建一个shell脚本.一个简单的是:

#!/bin/sh

ssh -t "$*"
Run Code Online (Sandbox Code Playgroud)

把它保存为ssh-t或者某种东西,chmod +x ssh-t把它放在你的某个地方PATH.然后设置GIT_SSH=ssh-t告诉Git使用这个脚本.