Made silly changes to /etc/passwd, now locked out :-(

Discussion about using NAS on Linux and Unix OS.
Post Reply
mrchris76
New here
Posts: 4
Joined: Sat May 24, 2008 6:15 am

Made silly changes to /etc/passwd, now locked out :-(

Post by mrchris76 »

Hi all, not sure what forum to post this but its more of a linux-ish issue so this will do hopefully!

Basically I have done something daft and can no longer ssh into my ts-109 using the admin account. :oops:

I manually edited /etc/passwd and changed the shell to be /bin/bash (as i had installed bash via optware).

I can't ssh in using another account, connection drops so i am assuming only the builtin "admin" account is allowed to do this. Can anyone suggest a way out of this mess? I can still access via the web interface of course, just ssh'ing in is no longer possible.

Thanks!
User avatar
AndyChuo
Experience counts
Posts: 2388
Joined: Thu Sep 13, 2007 11:56 am
Location: Taipei, Taiwan

Re: Made silly changes to /etc/passwd, now locked out :-(

Post by AndyChuo »

On the back of you NAS there's a small hole where you can press to get the password to reset to it's default which is admin/admin :)
=============================================================>>>
TS-659-Pro [RAID6] rtorrent+SABnzbdplus+SickBeard+Couchpotato [Best PVR] Plex+PMS [Ultimate Streamer]
Apple iPad [Best Tablet] HTC One M8 [Mobile Phone] Samsung UA46ES6100 [My Screen] KRK Rokit 6 [Audio Speakers]
Chrome Cast [Screen Casting] Philips Hue [Personal Lighing]
Buffalo WZR-1750DHP [My Wifi Hub] D-Link DGS-1005D [Gbit Network]
=============================================================>>>
mrchris76
New here
Posts: 4
Joined: Sat May 24, 2008 6:15 am

Re: Made silly changes to /etc/passwd, now locked out :-(

Post by mrchris76 »

Thanks I wasn't aware of that.

I know the password though thats not the problem, I have changed the admin account shell to bash (instead of /bin/sh) which it cannot find upon login as I installed bash using optware. So no valid shell means i get booted straight out of a login.

Just went to mount the disk in a ubuntu machine but its formatted as ext4 :-( can't read it.

Fedora 9 apparently has ext4 built in so downloading the livecd of that now...

edit: nope livecd doesn't have ext4 support
User avatar
AndyChuo
Experience counts
Posts: 2388
Joined: Thu Sep 13, 2007 11:56 am
Location: Taipei, Taiwan

Re: Made silly changes to /etc/passwd, now locked out :-(

Post by AndyChuo »

did you write somethign in the autorun.sh to copy bash to /bin?
and so it starts every time doing that and so you can't get in?
=============================================================>>>
TS-659-Pro [RAID6] rtorrent+SABnzbdplus+SickBeard+Couchpotato [Best PVR] Plex+PMS [Ultimate Streamer]
Apple iPad [Best Tablet] HTC One M8 [Mobile Phone] Samsung UA46ES6100 [My Screen] KRK Rokit 6 [Audio Speakers]
Chrome Cast [Screen Casting] Philips Hue [Personal Lighing]
Buffalo WZR-1750DHP [My Wifi Hub] D-Link DGS-1005D [Gbit Network]
=============================================================>>>
mrchris76
New here
Posts: 4
Joined: Sat May 24, 2008 6:15 am

Re: Made silly changes to /etc/passwd, now locked out :-(

Post by mrchris76 »

No I just installed optware, then bash amongst other things. Ssh'd in, fancied having bash as default shell for admin account, changed /etc/passwd manually using vi and then next time i tried to log in it was not possible due to bash not being a valid shell. Can't get in using normal user account as it seems only "admin" can do this...

going through the tedious process of moving all my files off at the moment to wipe the whole thing :-(

Unless theres something else i can try....?
whomever21
Starting out
Posts: 33
Joined: Wed Jul 02, 2008 12:56 am

Re: Made silly changes to /etc/passwd, now locked out :-(

Post by whomever21 »

As much as I hate the QNAP overwriting my sshd_config, proftpd.conf, and smb.conf files, I do wish there were some safeguards against damaging the system critical files. Think on it QNAP.

Anyway, I realize this comes far too late to help you now, but one solution might have been to mount the drive on your computer with a SATA to USB adapter. That way you could change the path in passwd from /bin/bash to /opt/bin/bash, which is probably what you meant to do in the first place. Sorry =/
Lobin
New here
Posts: 4
Joined: Sun Sep 14, 2008 4:08 am

Re: Made silly changes to /etc/passwd, now locked out :-(

Post by Lobin »

I've just spend few days resolving the same problem, and finally SOLVED IT!!!

Get disk or disks from NAS and connect them to another computer. Start Linux (or Linux live CD, I've used ubuntu live for myself).

RAID1 disk is created with utility called "mdadm" which makes SW RAID on Linux.

- Scan disks with "sudo mdadm --examine --scan >> /etc/mdadm/mdadm.conf"
- Assemble existing RAID array "sudo mdadm --assemble"
- Mount disks with "mount /dev/md0,9,13 ..." (depends on system)
- On one of mounted disks find directory /.config/passwd
- Change shell back to /bin/sh, or maybe you can change it to /opt/bin/bash, must be done as root so "sudo vi .config/passwd"

Get those drives back to NAS and boot!
When booting /etc/passwd file is symlinked from /mnt/HDA_ROOT/.config/passwd (which is our edited .config/passwd)

IT WORKS AGAIN :)
kwiksand
New here
Posts: 4
Joined: Tue Jan 06, 2009 11:35 pm

Re: Made silly changes to /etc/passwd, now locked out :-(

Post by kwiksand »

Damn, I stuffed that one up, I forgotten I'd installed busybox in the shell of my TS409Pro and changed /etc/passwd to use /bin/bash instead of the /bin/sh! (like above)

The disks are in RAID5, and i have little to no access to a machine with 4 disks in it, any other way of resetting the /etc/passwd? No QPKG or something??!?!?
User avatar
schumaku
Guru
Posts: 43578
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
Contact:

Re: Made silly changes to /etc/passwd, now locked out :-(

Post by schumaku »

Had a chat with a QNAP engineer in the background - here the idea:

- Shutdown the system and remove the drives
- Boot, login using telnet to port 13131 (ssh is disabled by default AFAIK)
- Hot plug the drives
- Assemble the system RAID partition, e.g. for a 4 HDD system:
# mdadm -A /dev/md9 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
- mount /dev/md9 to /mnt/HDA_ROOT

Then you should be able to find "your" modded passwd file on /mnt/HDA_ROOT :mrgreen:

When fixed - reboot!

Good luck!

-Kurt.
kwiksand
New here
Posts: 4
Joined: Tue Jan 06, 2009 11:35 pm

Re: Made silly changes to /etc/passwd, now locked out :-(

Post by kwiksand »

Thanks Kurt, these instructions worked and I'm back in now, thanks all!
chriswoah
New here
Posts: 2
Joined: Wed Apr 07, 2010 9:55 pm

Re: Made silly changes to /etc/passwd, now locked out :-(

Post by chriswoah »

schumaku wrote:Had a chat with a QNAP engineer in the background - here the idea:

- Shutdown the system and remove the drives
- Boot, login using telnet to port 13131 (ssh is disabled by default AFAIK)
- Hot plug the drives
- Assemble the system RAID partition, e.g. for a 4 HDD system:
# mdadm -A /dev/md9 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
- mount /dev/md9 to /mnt/HDA_ROOT

Then you should be able to find "your" modded passwd file on /mnt/HDA_ROOT :mrgreen:

When fixed - reboot!

Good luck!

-Kurt.
Brilliant instructions. I have also done this to myself. Bah. I've been away from linux for awhile, and am now just remembering how careful I have to be. (Last weekend I accidentally deleted my /usr/lib directory on my mac. I recovered it eventually, having backed it up, but tar no longer worked, and gzip isn't included by default on the mac boot image. But I digress...)

In my case (QNAP 439 Pro), telnet wasn't enabled by default but ssh was.

Thank you very much.
Chris
ianwinter
Starting out
Posts: 21
Joined: Tue Jul 15, 2008 8:42 pm

Re: Made silly changes to /etc/passwd, now locked out :-(

Post by ianwinter »

I've done the same, and fixed it (thank you!) but have a question.

I have a RAID5 and when I put all 4 disks in it locked me out again. I did it with 3, changed the file, rebooted and it's fine but will this have had a negative effect anywhere? I am correct in thinking the array will rebuild itself as it can sustain 1 drive failure? (needed a --run on the mdam command).
TS-409 Pro (3.3.2 build 0918T)
4 x Western Digital WD1000FYPS RE2-GP 1TB drives (RAID5)
iMac 10.11.5
wanrover
First post
Posts: 1
Joined: Fri Feb 18, 2011 6:32 am

Re: Made silly changes to /etc/passwd, now locked out :-(

Post by wanrover »

schumaku wrote:Had a chat with a QNAP engineer in the background - here the idea:

- Shutdown the system and remove the drives
- Boot, login using telnet to port 13131 (ssh is disabled by default AFAIK)
- Hot plug the drives
- Assemble the system RAID partition, e.g. for a 4 HDD system:
# mdadm -A /dev/md9 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
- mount /dev/md9 to /mnt/HDA_ROOT

Then you should be able to find "your" modded passwd file on /mnt/HDA_ROOT :mrgreen:

When fixed - reboot!

Good luck!

-Kurt.
Thank you Kurt,

Excellent tip, saved my day after shelling my passwd :oops:
Only difference is that my TS-419P+ has SSH enabled by default.
Post Reply

Return to “Linux & Unix (NFS)”