Stobbej
Stobbej

Reputation: 1090

Running a script automatically when logging in via ssh

I would like to know if there is a (simple) solution to the following issue:

When I log in with ssh to a specific host, I would like to automatically execute a (bash)script on that host. This way I could -for example- load my aliases on that host.

Definitively the bashrc script is not executed; The ssh configuration files do not seem to help in this issue either.

Any suggestions?

Thanks in advance!

BTW: The host is running on Gentoo

Upvotes: 1

Views: 976

Answers (2)

pjmorse
pjmorse

Reputation: 9304

If .bashrc isn't being run, try .profile, which has a similar function. Different shells use different startup scripts at different times, so knowing when to run things is useful.

Upvotes: 2

Olfan
Olfan

Reputation: 579

On many systems where you have a choice of which shell to use, you are put through ~/.profile only. This way there is no need to find out (and no probably wrong guessing) which shell you're running in and which profile to actually load (.bashrc, .cshrc, .kshrc etc.) and which ones to avoid loading.

The easiest solution in your case would be to create a link (a symbolic one if you prefer visibility) to your favourite shell's startup script as in ln -s ~/.bashrc ~/.profile. If you don't intend to ever using anything other than bash, you're set.

Upvotes: 1

Related Questions