I want to be able to ssh to some user(Linux), and use his environment variables that are located inside his .profile file in his machine:

ssh user@add "echo $VA"

And lets say user@add has an environment variable VA in his .profile file in his machine. How can I do that? From what I understand when I ssh into someone's machine I'm in 'non interactive shell' and I can only use the environment variables which located in /etc/environment

1 Answer 1

ssh user@add 'source .profile ; echo $VA'

You want to use single quotes in your command otherwise you will fill in the value of VA on the local machine before you connect to the remote machine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .