Linux/SSH - get EC2 instance to read local .bashrc file

2

I have a custom .bashrc file with color codes locally on my Linux machine running Ubuntu 12.04 for both my user and root. I connect to Amazon EC2 instances daily running the same distro and would like to somehow use the same .bashrc files for my user and root without having to manually create them since we'd like to keep the instances generic seeing as multiple developers ssh to them.

Is it possible to have an EC2 instance read from my local .bashrc file during a session so I can have the same color scheme as my local bash prompt?

dcd0181

Posted 2013-09-22T20:36:37.507

Reputation: 247

Answers

2

Yes it is possible but really not worth the effort. Just copy the file over or create a new file on the EC machine and source it from your .bashrc there:

. $HOME/home_bashrc

You can then delete it whenever you want.


Anyway, one way of sourcing your actual home ~/.bashrc is to set up passwordless ssh from the EC server to your machine and then add this line to your EC ~/.bash_profile:

scp user@local:/home/user/.bashrc $HOME/home_bash && source $HOME/home_bash

Then, add this to your ~/.bash_logout:

rm $HOME/home_bash

That way, the file will be deleted as soon as you log out.

terdon

Posted 2013-09-22T20:36:37.507

Reputation: 45 216

I like deleting it on logout.. Agreed, not worth the effort – dcd0181 – 2013-09-23T04:01:28.347

1

Completely untested: if, from the remote server, you can ssh back to your local machine, then you could do:

. <(ssh user@local 'cat .bashrc')

Or, you could copy your .bashrc to the remote server as .bashrc_dcd018 and source that.

glenn jackman

Posted 2013-09-22T20:36:37.507

Reputation: 18 546