Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have my bashrc file set up to my liking.I usually work on a hardware that is plugged into a remote server.I ssh into that remote server.I would like my .bashrc to be run when I ssh into the remote server,instead of the bashrc on the server.Is there anyway by which I can accomplish this.?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

AFAIK, there is no way to do that.

Maybe you should copy your ~/.bashrc to a server and install a configuration management tool (Puppet, Chef, ...) on all the other servers to pull it.

share|improve this answer
Another suggestion for the same problem.I could write a bash function which does ssh to the remote machine,does an scp of ~/.bashrc to a folder on the remote machine and does a bash with that bashrc as the parameter. –  liv2hak Aug 16 '11 at 0:58
While working with Puppet, Chef, etc, will set the OP on the right path, it seems a bit overkill for simply having .bashrc updated. –  gtirloni Sep 12 '14 at 18:03

I think sshrc is what you're looking for: https://github.com/Russell91/sshrc

sshrc works just like ssh, but it also sources ~/.sshrc after logging in remotely.

$ echo "echo welcome" > ~/.sshrc
$ sshrc me@myserver

$ echo "alias ..='cd ..'" > ~/.sshrc
$ sshrc me@myserver
$ type ..
.. is aliased to `cd ..'

You can use this to set environment variables, define functions, and run post-login commands. It's that simple, and it won't impact other users on the server - even if they use sshrc too. For more advanced configuration, continue reading.

share|improve this answer
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  gtirloni Sep 12 '14 at 11:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.