I've got a script, named s, on a remote server that activates a virtual environment like this:source venv/bin/activateWhen SSH-ed into the server, I'm able to activate the environment by. sAnd I SSH into the server as following:ssh -t user@host cd /path/to/dir ; /bin/bashIn addition to changing the working directory to /path/to/dir it would be nice if I could activate the environment right away each time I log into the server. But no matter where I put . s into the the SSH command, using -c for /bin/bash or not, the session always ends immediately.
SSH into a remote shell, execute a 'source' command, and stay in the remote shell
bash;shell;ubuntu;ssh
Use a new source file e.g. /home/user/.rcforssh #rc for ssh . /home/user/.bashrc . /home/user/venv/bin/activate  #or whichever locationand log in with ssh -t user@host cd /path/to/dir ; /bin/bash --rcfile /home/user/.rcforsshSide note: source is not POSIX, while . is.UPDATE following discussion specifying OP's needs:For creating and removing the the modified source file rcforssh on the fly, on can use:ssh -t user@host cd /path/to/dir ; echo '. ~/.bashrc ; . s ; rm rcforssh' > rcforssh ; /bin/bash --rcfile rcforsshi.e. creating the source file with an echo command and adding the removal in said file.