How to autorun commands on OSX when ssh remotely?

296 views Asked by At

How to autorun commands on OSX when login remotely?

Is there a file, which is executed automatically when you ssh on iMac, like .bashrc on linux?

I tried .bashrc, .login, /etc/profile, nothing works.

1

There are 1 answers

0
Anya Shenanigans On BEST ANSWER

Because you're using a login shell the .bashrc file is not sourced. In this case the rules for bash are quite clear:

The default login behaviour is it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.

Also note that: When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option.