Added 'exit 0' to the bottom of .bashrc, now what?
Centos 6.5
I ran into an interesting problem (on reddit) that I figured I could solve, but I have not been able to. Its simple,.. I added 'exit 0' to /root/.bashrc, and now I am trying to log in via ssh. Everytime I do, it immediately exits when it runs the .bash_profile, which sources .bashrc, (which is immediate upon 'logging in') I've tried: Code:
ssh root@192.168.1.50 -t vim Anyone feel like explaining why all of these failed (aside from saying SSH interactive logins run the .bash_profile/.bashrc files) or, offering a suggestion that works? Seems like if you have the root password, you should be allowed to modify the login process... since... you know... you are root. |
If all of those failed to let you edit .bashrc or remove it, then you have a different problem than just an exit.
Also, hi from Reddit (though that guy says he fixed it). |
Correct. Tried all the solutions, none work. I have access to the machine, it works fine until I put exit 0 at the bottom of .bashrc
After that, no combination of --norc --noprofile, scp, sftp, /bin/bash, commands etc etc have any affect at all. Its literally a base install of centos built for this testing only. Everything is default except the 'exit 0' at the bottom of .bashrc |
Boot the machine from live CD at the console and edit /root/.bashrc from there.
|
Ummm... don't do that.
bashrc is run in the same context as the users login shell - thus an exit logs the user out. And in the list of things of "don't put exit in": .login .profile .bashrc .cshrc .xinit .xsession Exits can be used in any script that is not run as part of the users login shell - all it does then is terminate the process. It can be used in other places - but you have to expect to be logged out. |
Quote:
Its a virtual machine built for testing this. Of course I can boot into single user mode and edit it, but that isnt the point. |
Quote:
|
Well I am no ssh guru, but I found one idea and had a left of centre one:
Found: Code:
~/.ssh/rc |
What if you were to use sshfs to remotely mount root's home directory on another machine and edit it there?
|
Quote:
|
Brain isn't working well today but how about using rsync or scp to copy over an "empty" .bashrc file?
|
Quote:
Anything that terminate the shell will also terminate the scp. |
Quote:
|
Quote:
Code:
/bin/bash --norc --noprofile Code:
bash -c /bin/bash --norc --noprofile I haven't looked at the sshd code to see if maybe there are different options to give different behaviors or if there is something in the default configs, which might explain the distribution differences. With the way Centos and RHEL are working, I don't see a way to get it to work because I can't see a way to either stop the processing of the .bashrc or override the shell. |
That was why I suggested using the kernel parameter "init=/bin/bash --noprofile". This should bypass the system startup and allow you to use the initrd to do things (like mount root and fix things).
|
All times are GMT -5. The time now is 04:00 PM. |