Surpass sourcing .bashrc

Dear all,
I have performed a small blunder, which, although is interesting even.
Maybe its too obvious, but could anyone tell how can one login/scp/sftp into a
remote machine if the .bashrc on the remote machine contains the statement

exit 0
Yes, that is what I have done. I wrote statement exit 0 in the .bashrc of
remote machine and logged out.
Hence, I cannot relogin into the machine, neither scp not sftp into it.
Could anyone please help!
Thanks in advance.
:)
-kvaibhav

If you get the login prompt then you can vi the .bashrc file and remove the exit 0 from it. The bash -norc command allows logins without processing the .bashrc file. You may want to substitute the "bash -norc" with "vi .bashrc" and see if that works too.
Kevin Grimes
Test Engineering Technician
Flextronics S.C.

On executing your suggestion, following error was witnessed.
Vim: Warning: Output is not to a terminal
Vim: Warning: Input is not from a terminal
But this gave me a very neat idea. I executed it, and it
worked. I simply used :
$ ssh username@host "sed -i 's/exit 0//' .bashrc"
and it has worked.
That was indeed a very nice suggestion.
Thank you very very much.
:D
It has saved me quiet some effort.
Thanks once again.
:D
-kvaibhav
P.S.: Any comments over the above-mentioned vim error is most welcome!

;)

->
->
->
-> If you get the login prompt then you can vi the .bashrc file and remove the exit 0 from
-> it. The bash -norc command allows logins without processing the .bashrc file. You may
-> want to substitute the "bash -norc" with "vi .bashrc" and see if that works too.
-> Kevin Grimes
-> Test Engineering Technician
-> Flextronics S.C.
->

I have tested a command that will work for you. Do this
> "ssh user@host 'mv .bashrc mybashrc'"
> then reconnect with "ssh user@host" and
> vi the mybashrc file to remove the exit 0 line and rename it back to .bashrc when completed.

Ok !
This is getting even better.
The machine that the solution worked on, was on campus.
But I need to hop from here, to some other machine, and it does not
work there. I mean no command is executed on the machine unless one
actually logs in there.
I tried
ssh username@hostmachine 'bash -norc'
'ssh usernam@host "mv .bashrc .bashrc_exit"
ssh username@host "sed -i 's/exit 0//' .bashrc"
ssh -s "/usr/bin/sh" username@host

If you do not have a valid login on the machine you are attempting it on, it will not work. Does the node you are connecting to reside behind a proxy server?
Kevin Grimes
Test Engineering Technician
Flextronics S.C.

Copyright 1998-2015 Ziff Davis, LLC (Toolbox.com). All rights reserved. All product names are trademarks of their respective companies. Toolbox.com is not
affiliated with or endorsed by any company listed at this site.