Locked out from ssh

Don't miss a thing. Post your questions and discussion about other uncategorized NAS features here.

Locked out from ssh

Postby dmccormack » Mon Aug 20, 2012 3:30 pm

Hi

I have an x69 box with the latest firmware, 3.7.3

I did a reboot this morning and now I am locked out of ssh :( but I can login ok over the web admin interface. A few things I've noticed and this may be where my issue is.
Since the last reboot I have changed the shell for the admin user in /etc/passwd to /opt/bin/bash, from the optware package.
When I look at the list of installed qkpg's in the web interface, it is now empty. I tried to reinstall the optware package, but it throws me an error.

So it looks like something went seriously wrong during reboot, optware got deleted, I can no longer install it and I now have no shell to login.

What can I do here?
dmccormack
Starting out
 
Posts: 15
Joined: Wed Apr 27, 2011 9:13 pm
NAS Model: TS-x69 Pro

Re: Locked out from ssh

Postby Don » Mon Aug 20, 2012 8:10 pm

Did you try telnet?
Search (upper right hand corner) before posting.

Unofficial QNAP How-To Guide: http://forum.qnap.com/viewtopic.php?f=11&t=10622
How-To increase raid rebuild speed: http://forum.qnap.com/viewtopic.php?f=11&t=10268
How-To install dnsmasq: http://forum.qnap.com/viewtopic.php?f=90&t=26395

NAS: TS-509 F/W 3.6.1.0302 | TS-419P+ F/W 3.8.2.0301 | TS-639 F/W 3.6.1.0302 | TS-669 F/W 3.8.2.0301
QPKG: ipkg, LMS 7.7.1, PhpGedView, phpMyAdmin, WordPress, Xdove 1.3
IPKG: atop, busybox, dnsmasq, flac, htop, lame, less, libid3tag, lsof, man, man-pages, unzip, wakelan
OTHER: crontab, phpXmail, SpeedTest
N/W: Asus RT-N16 router w/dd-wrt | SMC gigagit switch
User avatar
Don
Moderator
 
Posts: 5526
Joined: Thu Jan 03, 2008 4:56 am
Location: Long Island, New York
NAS Model: TS-509 Pro

Re: Locked out from ssh

Postby dmccormack » Mon Aug 20, 2012 8:43 pm

Ah yes, forgot about telnet. Will give that a try later.

Just remember that I also changed the ssl certs since last reboot and I don't think I have the private key in my ssh folder. Although I doubt that would be an issue as I've been able to login without a problem until the reboot today.
dmccormack
Starting out
 
Posts: 15
Joined: Wed Apr 27, 2011 9:13 pm
NAS Model: TS-x69 Pro

Re: Locked out from ssh

Postby dmccormack » Tue Aug 21, 2012 1:29 am

It looks like this is not an SSL issue and what I originally thought it the problem.

I tried to telnet in and it also failed with the error:

Code: Select all
sh: pts/0: No such file or directory
Cannot execute /opt/bin/bash: No such file or directory
Connection closed by foreign host.


This looks like a very serious issue from QNAP. The reboot deleted all my qpkg's, there are none in the list in the web ui and it won't allow me to re-install them. The etc/passwd is trying to load the bash shell that I was installed with the Optware qpkg, but that now appears to be missing and I can't login using ssh or telnet to rectify this.

What can I do here?
dmccormack
Starting out
 
Posts: 15
Joined: Wed Apr 27, 2011 9:13 pm
NAS Model: TS-x69 Pro

Re: Locked out from ssh

Postby dmccormack » Tue Aug 21, 2012 2:33 am

success :D

I did a restore from a backup and my apps reappeared in the qpkg list but they were not started. I was able to delete the optware qpkg and this allowed me to install it again and enable it. After that I could login again.

This is a massive bug and I see that a lot of other people here have the same issue, I think I will refrain from rebooting the machine for now.
dmccormack
Starting out
 
Posts: 15
Joined: Wed Apr 27, 2011 9:13 pm
NAS Model: TS-x69 Pro

Re: Locked out from ssh

Postby tmt » Tue Aug 21, 2012 5:53 am

dmccormack wrote:Since the last reboot I have changed the shell for the admin user in /etc/passwd to /opt/bin/bash, from the optware package.


That is *extremely* inadvisable. The /opt hierarchy is not available until the Optware package is initialized, which is quite late in the boot process. And in the meantime, any admin shell activity will simply fail, which potentially prevents the boot from processing.

Don't change the settings of the default users. Instead, create new users and tweak them to your heart's content.
SS-439, Ubuntu Server 12.04.2 LTS, EXT4, RAID10, 4xHitachi 5K1000
TS-112, 3.7.3 20120801, EXT4, 1xHitachi 7K1000
tmt
Been there, done that
 
Posts: 978
Joined: Mon Nov 16, 2009 11:02 am
NAS Model: SS-439 Pro

Re: Locked out from ssh

Postby schumaku » Wed Aug 22, 2012 4:13 am

tmt wrote:
dmccormack wrote:Since the last reboot I have changed the shell for the admin user in /etc/passwd to /opt/bin/bash, from the optware package.


That is *extremely* inadvisable.
Yes - tmt explained very appropriate.
User avatar
schumaku
Guru
 
Posts: 22317
Joined: Mon Jan 21, 2008 4:41 pm
Location: Kloten (Zurich), Switzerland -- Skype: schumaku
NAS Model: TS-x79 Pro

Re: Locked out from ssh

Postby dmccormack » Wed Aug 22, 2012 7:20 pm

Cheers guys, I've changed the shell back and will manually change it when I log in.
dmccormack
Starting out
 
Posts: 15
Joined: Wed Apr 27, 2011 9:13 pm
NAS Model: TS-x69 Pro

Re: Locked out from ssh

Postby muwlgr » Fri Sep 14, 2012 5:21 pm

Dear dmccormack ,

can you please explain how you changed your shell back ?
what utility/facility did you use to change /etc/passwd file ?
I am in the similar situation, and your advise will be helpful.
muwlgr
New here
 
Posts: 6
Joined: Fri Apr 13, 2012 2:02 pm
NAS Model: TS-809 Pro

Re: Locked out from ssh

Postby pwilson » Sat Sep 15, 2012 7:41 am

Do yourselves a favour: Do NOT change the shell field in the passwd file.

If you really want to have "bash" simply load it via your ".bashrc" , ".profile" or ".bash_profile" file instead. This way if it fails, you'll simply get an error when it tries to load, but your busybox (/bin/sh) will still be there, and will still be functional. If "bash" is there, it will load on top of busybox, and you will be able to use it to your hearts content. Simply make /opt/bin/bash the last command in your script.

Changing your passwd "shell" field to something that is not provided in the firmware, is what caused your issues in the first place. If you use the ".bashrc" method, you will not get locked out if Optware isn't mounted on your /opt directory when you log into your NAS.

As has been explained multiple times in this thread already, changing your shell in the /etc/config/passwd file is a less than a smart move. (For reasons you've already discovered). Why would you do it again, after recovering from this poor decision?

Patrick.

Patrick M. Wilson
Victoria, BC Canada
QNAP TS-419P+ w/ 4 * Seagate Barracuda 2TB 5900rpm (RAID5) - FW: 3.8.1 Build 20121205
Forums: View My Profile - Search My Posts - Send Private Message - View My Photo - Top Community Forum Posters
QNAP: Turbo NAS User Manual - QNAP Wiki - QNAP Tutorials - QNAP FAQs - HowTos - QNAP Video Library
User avatar
pwilson
Moderator
 
Posts: 3822
Joined: Fri Mar 06, 2009 11:20 am
Location: Victoria, BC, Canada
NAS Model: TS-419P+


Return to Miscellaneous

Who is online

Users browsing this forum: Newt and 5 guests