在 ssh 会话中启用 tty [英] enabling tty in a ssh session
问题描述
我想为编写的脚本获取一些登录信息,供许多用户使用.在 python 中,我将 input_raw 设置为从 dev/tty 读取,但是当我通过 ssh 连接到在服务器上运行的脚本时,它失败了.
想法?解决方法?
我宁愿避免将用户名硬编码到脚本中.
请和谢谢.
尝试使用 -t
选项进行 ssh:
~/.ssh/config
中似乎没有等效选项,因此您需要创建一个 shell 脚本.一个简单的就是:
#!/bin/shssh -t "$*"
将其另存为 ssh-t
或其他内容,chmod +x ssh-t
,并将其放在您的 PATH
中的某个位置.然后设置 GIT_SSH=ssh-t
告诉 Git 使用这个脚本.
I would to take in some login information for a script have written in to be used by many users. In python I set the input_raw to read from dev/tty but it fails horribly when i am connecting to the script being run on a server through ssh.
Thoughts? Workarounds?
I would prefer to avoid hard coding usernames into the script.
Please and thank you.
Try using the -t
option to 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.
There doesn't seem to be an equivalent option in ~/.ssh/config
, so you will need to create a shell script. A simple one is:
#!/bin/sh
ssh -t "$*"
Save this as ssh-t
or something, chmod +x ssh-t
, and put it somewhere in your PATH
. Then set GIT_SSH=ssh-t
to tell Git to use this script.
这篇关于在 ssh 会话中启用 tty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!