views:

130

answers:

1

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  A: 

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.

Greg Hewgill
That probably would have worked, but I am starting that ssh connection through a git push. Is there a way to inject the -t option?
garbagecollector
@garbagecollector: The [GIT_SSH](http://www.kernel.org/pub/software/scm/git/docs/) environment variable tells Git which command to use for ssh. As explained on that page, to pass options to ssh you can wrap it in another shell script, or use `~/.ssh/config` (I'd recommend the latter).
Greg Hewgill
Could you please write a simple example injecting the -t options using the '.ssh/config' method
garbagecollector
@garbagecollector: According to [SSH - How to include “-t command” in the ~/.ssh/config file](http://serverfault.com/questions/56086/ssh-how-to-include-t-command-in-the-ssh-config-file), there doesn't seem to be an equivalent config option for -t. I would create a shell script instead (see edited answer).
Greg Hewgill