View Full Version : Console crashed while VI editing /etc/passwd
anjin
2004-09-22, 04:51 AM
I know, it was stupid. But let's not make fun of me and instead be constructive ;)
PuTTy crashed in the middle of me using the VI editor to give a user root access. Logging in now for any user returns an incorrect password error. I thought that when you worked on a document in VI it was actually a buffer file and did not modify the original until being directed to do so..
Is there a way to get in there remotely now that the passwd file is apparently corrupt?
bow-wow
2004-09-22, 11:43 AM
It sounds like you're SOL. If you can't login remotely then I doubt anyone [at SB] will be able to login locally either. Open a trouble ticket. They'll probably have to boot into single user mode to fix it, if the problem is indeed a corrupt passwd file.
Never edit /etc/passwd directly. Use the tools provided (useradd,usermod,userdel,chsh) and you'll avoid this scenario in the future.
Good luck :)
Bow-wow is correct, you are probably going to have to submit a support ticket if you are not able to login through ssh or webmin (if its installed).
anjin
2004-09-22, 15:03 PM
Thank you very much for the quick response!
I can login to example.net/admin under the same username I'm having trouble with in FTP and PuTTy; is that significant? I sort of doubt I'll be able to do much in cpanel though - I'm not sure if that's what you mean by webmin QT.
Editing the /etc/passwd file was a last resort bow-wow; I had in fact attempted to use those commands logged in under root, but they returned a "cannot find command" error. A friend then pointed out that I needed to log in with "su -", and I smacked myself in the forehead! :bang:
Whatever the result, I'll post the outcome, clarify the original problem, and ways to fix it for the reference of other such noob/unlucky/stupid linux/apache users such as myself.
Thanks again! :thanks:
anjin
2004-09-22, 15:55 PM
I have actually had success in logging in under one of my clients usernames, but - and stop me if I'm wrong here, I'm a novice at this - the client is on a virtual site, which effectively creates their own mini-server (and hence /etc/passwd files). Is that correct? I "view passwd"ed the file and it appears VERY different from the backup of the original global passwd file I saved before the problem occured.
But it does have a 'root' in there, which is unresponsive to my known passwords.
Ideas?
You aren't going to be able to do anything, cpanel sets up users inside of a jailshell. In the future, "vipw" is the preferred method of editing the passwd/shadow files if it is absolutely necessary to do (thats is only if something needs to be changed and the other tools that bow-wow mentioned wont do the job). :)
tonythor
2004-09-22, 18:10 PM
Never edit your password file with vi.
Use the command vipw, it's a special command that does a bunch of checks before it rewrites the file. If you don't have vipw on your distro, go get it.
Live and learn.
I did the same thing on a solaris box about 5 years ago. My senior unix guy ended up going in and loading the kernel from CD, which is probably what you're going to have to do.
tony fraser
fastduke
2004-09-22, 21:32 PM
We all do stupid stuff and we must never repeat it :D
Just to share my most stupid mistake:
#chown -R joeuser1:students ./ :eek:
Yeah you can probably guess but it wasn't as bad as it could have been. Luckily I was in /home/students and I only gave joeuser1 access to like 700+ student accounts :bang:
Anyway a few lines of perl and minutes later the permissions were restored :P
Oi! Good thing you weren't in / !
;)
tonythor
2004-09-23, 12:08 PM
I did it once, not from root, but from /usr/bin or /usr/sbin, I don't rememer exactly which.
Yeah... Seriously.
I had just started using 'cd -' with bash and didn't have my directory set in my title bar or in the prompt.
Turned out to not be such a big deal though. I just didn't reboot the system and scp'd all the files over from a cold backup.
That was during boom though. Some of you may remember it, sleeping 2 hours per night and living in server rooms. We were creating our own work I sometimes think.
tf
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.