os.environ.get('SSH_ORIGINAL_COMMAND') returns None

Tim Roberts timr at probo.com
Tue Dec 16 08:23:02 CET 2008


Tzury Bar Yochay <Afro.Systems at gmail.com> wrote:
>
>added to ~/.ssh/authorized_keys the command="my_parder" 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?

The SSH_ORIGINAL_COMMAND variable is set to the command that was passed in
on the ssh command line.  Since you are not specifying a command, you
aren't going to find anything in that variable.

Try this:
    ssh localhost 'ls -l'
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list