Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我会为编写的脚本获取一些登录信息以供许多用户使用。在 python 中,我将 input_raw 设置为从 dev/tty 读取,但是当我通过 ssh 连接到在服务器上运行的脚本时,它严重失败。
想法?解决方法?
我宁愿避免将用户名硬编码到脚本中。
谢谢,麻烦您了。
尝试使用-tssh 选项:
-t
-t 强制伪 tty 分配。这可以用来执行仲裁 将基于屏幕的程序放在远程机器上,可以是 非常有用,例如在实现菜单服务时。多个 -t 即使 ssh 没有本地 tty,选项也会强制分配 tty。
中似乎没有等效选项~/.ssh/config,因此您需要创建一个 shell 脚本。一个简单的方法是:
~/.ssh/config
#!/bin/sh ssh -t "$*"
将此另存为ssh-t或其他内容,chmod +x ssh-t并将其放在您的PATH. 然后设置GIT_SSH=ssh-t告诉 Git 使用这个脚本。
ssh-t
chmod +x ssh-t
PATH
GIT_SSH=ssh-t