Skip to content

Instantly share code, notes, and snippets.

@rousan
Last active July 18, 2021 02:51
Show Gist options
  • Save rousan/64d1f578cbe9a7f45f3456a9a9b03b07 to your computer and use it in GitHub Desktop.
Save rousan/64d1f578cbe9a7f45f3456a9a9b03b07 to your computer and use it in GitHub Desktop.

How to execute the .bashrc file with command running through SSH login?

I wanted to use command

ssh myhost.com 'some_command' and some_command exists in /var/some_location so I tried to append /var/some_location in $PATH environment by editing $HOME/.bashrc

but that wasn't working. because default .bashrc(Ubuntu 10.4 LTS) prevent from sourcing by code like below:

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

So If you want to change environment for ssh non-login shell. you should add code above that line.

Ref: https://stackoverflow.com/questions/820517/bashrc-at-ssh-login

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment