So let's say one typoed something in their .bashrc
that prevents him (or her) from logging in via ssh
(i.e. the ssh login exits because of the error in the file). Is there any way that person could login without executing it (or .bashrc
since the one runs the other), or otherwise delete/rename/invalidate the file?
Suppose you don't have physical access to the machine, and this is the only user account with the ability to ssh in.
For Reference: .bash_profile
includes .bashrc
:
[[ -f ~/.bashrc ]] && . ~/.bashrc
Edit: Things I have tried:
ssh user@host "rm ~/.bashrc"
scp nothing user@host:/RAID/home/tom/.bashrc
ssh user@host "/bin/bash --norc"
All give the error:
/RAID/home/tom/.bashrc: line 16: /usr/local/bin/file: No such file or directory
/RAID/home/tom/.bashrc: line 16: exec: /usr/local/bin/file: cannot execute: No such file or directory
[ -z "$PS1" ] && return
at the beginning of ./bashrc. This way scp will stop parsing .bashrc after the first line, and you will be able to overwrite it in case of emergency.