tags:

views:

1193

answers:

1

Trying to follow a technique found at bzr and gitosis I did the following:

added to ~/.ssh/authorized_keys the command="my_parser" parameter which point to a python script file named 'my_parser' and located in /usr/local/bin (file was chmoded as 777)

in that script file '/usr/local/bin/my_parser' I got the following lines:

#!/usr/bin/env python
import os
print os.environ.get('SSH_ORIGINAL_COMMAND', None)

When trying to ssh e.g. ssh localhost I get None on the terminal and then the connection is closed.

I wonder if anyone have done such or alike in the past and can help me with this.

Is there anything I should do in my python file in order to get that environment variable?

+1  A: 

$SSH_ORIGINAL_COMMAND is set when you connect to a host with ssh to execute a single command:

$ ssh username@host 'some command'

Your "my_parser" would then return "some command".

Unless you invoke a shell with my_parser, it will then exit, and the connection will close. You can use this to control the environment of the remotely executed commands, but you lose the ability to have an interactive session

JimB