Run Remote ssh command with Full Login Shell

ssh

I would like to do something like ssh example.com 'ls' However per ssh manpage:

If command is specified, it is
executed on the remote host instead of
a login shell.

So what happens is that ls displays its output and then ssh exits.

What I can't figure out is how to have the full login shell open and then have the command run inside that shell. Leaving the shell open after the command is run. As if I had manually done the following:

  localhost$ ssh example.com 
example.com$ ls
             /folder1 
             /folder2 
example.com$ _

Any ideas?

Best Answer

Just tell bash to execute ls and then itself in a login shell

$ ssh user@host  -t 'bash -l -c "ls;bash"'