Bypass ~/.profile on remote login to a linux server

Is there a way to bypass or prevent the execution of ~/.profile when logging into a remote Linux server using either ssh or putty?


Solution 1:

For bash:

$ ssh hostname "bash --noprofile"

Solution 2:

If you are looking to disable all login scripts, you can use the --noprofile flag to disable /etc/profile, ~/.profile, etc. and --norc to disable ~/.bashrc like so:

$ ssh 127.0.0.1 "bash --noprofile --norc"

Keep in mind you can also launch an alternative shell if one is available. I've had to use this after messing up in chsh:

$ ssh 127.0.0.1 sh

This will most likely drop you to a blank shell (no prompt) so give it an ls to make sure it is working.