I have a myuserid@remotemachine on my network to which I have access via public/private key ssh (ie, doesn't prompt for password, logs me straight in). Is there a way, from Python (or bash, or any other standard linux command) on my local computer, to read one of myuserid's environment variables on remotemachine without needing to run a pre-prepared remote script?
sure, you can use ssh to run a remote command
try this in your terminal:
Short of running a remote process such as with this command from your local system or wherever your script runs (suggested by FangQ)...
...to get the output of the env var you've requested (in this case,
ENVVARNAME
in the example which is a bogus placeholder here), you can't.There is no way to get the entire list of environment variables without executing a process on the remote system. Therefore, short of running an SSH call into the remote environment to dump the env vars, and then parse that output, you won't be able to get 'remote' variables.
This applies to Python, Bash, and any other script language - either you have to retrieve the data via a remote process call and parse its output, or you have to run your script on the remote system.