I regularly have to log onto remote hosts via SSH and I like to use the bash option
set -o vi and I normally have to
cd to a specific directory. Since these hosts are ephemeral (they are created and destroyed regularly) I can't log onto them and save these in a
.bashrc. So I was looking into how I can do this when I connect via SSH so I don't have to type the same commands each time I connect to a remote server. I've tried several ways to achieve this but none of them seem to work. Can someone help me get this command right? In a nutshell this is what I want to do.
cdto a specific directory
- set the bash option
set -o vi
Here's how I've tried to do it:
ssh [email protected] -t "cd /data; exec bash --login -c \"set -o vi\""
I feel that this actually works but that the SSH session terminates because once the command
set -o vi is executed the session disconnects with a message like:
Shared connection to remotehost.com closed.
Is there a way to keep the session open after executing these commands or is there another way to achieve what I want?