I would like to be able to ssh
to a remote host and run some repetitive commands on it before continuing my work.
I have been trying the following command with no luck:
ssh uname@remotehost.com 'source /path/to/my/bashrc; ls /logs'
The commands run fine, however I am not being presented with a shell to continue my work.
What am I missing here?
Best Answer
You are missing one thing. That if you provide
ssh
command to run, the session will end as soon as the session ends. This mean as soon as yourls
command ends, alsossh
will return. To achieve your requested behaviour you need to add thebash
/shell
to the end and requesttty
allocation, like this:or you can substitute the
bash
command with other shell you prefer.