You can temporarily copy your .bashrc
to your remote machine with another name. For example, using .bashrc_temp
:
user@local$ scp .bashrc user@remote:~/.bashrc_temp
Afterwards you can log into the remote machine:
user@local$ ssh user@remote
and source
the file .bashrc_temp
:
user@remote$ source ~/.bashrc_temp
Now you are able to use your .bashrc
and your functions. When you are finished with your work you can remove the file ~/.bashrc_temp on the remote machine and logout.
The copying of the file and the login to the remote machine may be achieved with a bash function:
# copy the .bashrc to the remote machine
# and log into the remote machine.
# parameter $1: user@remote
function s() {
scp ~/.bashrc $1:~/.bashrc_temp
ssh $1
}
Update:
You may also consider to copy the .bashrc
to /tmp
on your remote machine and source /tmp/.bashrc_temp
.
Update 2:
You can log into the remote machine by using ssh -t. This will automatically use your temp .bashrc
. Updated function s()
:
function s() {
scp ~/.bashrc $1:/tmp/.bashrc_temp
ssh -t $1 "bash --rcfile /tmp/.bashrc_temp ; rm /tmp/.bashrc_temp"
}