Skip to main content
4 of 5
deleted 221 characters in body
JoL
  • 5k
  • 1
  • 20
  • 37

A solution based on Gilles's that doesn't require adding AcceptEnv on the server for LC_XXX:

ssh -t remote.example.com " exec bash --rcfile <( printf '%s' '$( sed "s:':'\\\\'':g" ~/.bashrc )' ) " 

That's to use your local ~/.bashrc in the remote session. It takes advantage of the fact that everything in between single-quotes in bash is taken literally, so the only thing we need to worry about escaping are the inner single quotes themselves. We can safely quote bash-code by surrounding it with ', and substituting inner 's for '\''s.

If you want to just a few aliases or something inline to the remote ~/.bashrc:

ssh -t remote.example.com " exec bash --rcfile <( printf '%s' ' . ~/.bashrc alias ll=\"ls -l\" ' ) " 
JoL
  • 5k
  • 1
  • 20
  • 37