I'm managing a bunch of servers so I frequently have to ssh into them. I'd like to automatically run a basic custom script on whatever remote server after logging in. Say to set up some aliases, colors for vim, PS1, and what-not.
I don't want to configure every server with a startup script, I want this to live locally on my computer and just get executed on whatever server I ssh into.
There are similar questions but after executing the script ssh logs out. How to stay logged in?
This answer is quite near, yet the new bash -l
does not seem to register the environment variables set like: ssh -t user@remote 'export PS1=myps1; bash -l'
. Here, PS1 is not set in the new prompt, maybe because some remote .bashrc
How could this be possible?
.bashrc
file is designed for. Can you explain why this does not fulfill your use case?scp ~/.bashrc user@remote:~/.bashrc && ssh user@remote