enabling tty in a ssh session

2020-06-23 05: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.