enabling tty in a ssh session

China☆狼群 提交于 2020-01-12 08:47:09

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3372268/enabling-tty-in-a-ssh-session

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!