Run Remote ssh command with Full Login Shell
Just tell bash to execute ls
and then itself in a login shell
$ ssh user@host -t 'bash -l -c "ls;bash"'
ssh user@host -t 'ls; exec $SHELL -l'
-t
Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine. Is slightly more proper than bash -i
.
exec
No new process is created.
-l
looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from ... Without this you probably can not run scripts/commands from ~/bin directory, because this code from ~/.profile will not be executed without -l
flag:
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi