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

T

Tzury Bar Yochay

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

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?
 
T

Tim Roberts

Tzury Bar Yochay said:
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'
 
Y

Yinon Ehrlich

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

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.

You should define SSH_ORIGINAL_COMMAND in environment of the calling
shell/application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top