Root access by SSH denied

Questions about IPKG can go here!
Forum rules
Please note the disclaimer before modifying your Synology Product.

Root access by SSH denied

Postby Nulkoud » Wed Mar 07, 2012 2:58 pm

Hello all,

Yesterday I upgraded from the beta 4 to the current 4 release. I noticed that I'm not allowed anymore to login via SSH with the root account. I can login with the admin account, but to get the opt ware working again, I need to have root access. Is there somebody who have the same issue?
Any idea howto fix this?

thanks
Nulkoud
I'm New!
I'm New!
 
Posts: 8
Joined: Fri Sep 24, 2010 4:22 pm

Re: Root access by SSH denied

Postby Kriskmk » Thu Mar 08, 2012 5:07 am

did you have the usual port 22 for ssh or something else? are you sure ssh is turned on in terminal? What error message if any are you getting?
Kriskmk
Novice
Novice
 
Posts: 52
Joined: Tue Mar 15, 2011 6:08 pm

Re: Root access by SSH denied

Postby Nulkoud » Thu Mar 08, 2012 8:26 am

Hi,

getting access with the admin account it working great, so ssh isn't the problem. I use Putty to login, when I try to login with the root account the window will close immediately.

When I'm logged in as admin and try to get root access with su, I get the following error:
su: must be suid to work properly

I googled the error and found that it should be a permissions issue with /bin/su. The problem is that I can't chmod /bin/su because admin seems not allowed to do that.

Any ideas?

Thanks
Nulkoud
I'm New!
I'm New!
 
Posts: 8
Joined: Fri Sep 24, 2010 4:22 pm

Re: Root access by SSH denied

Postby bud77 » Thu Mar 08, 2012 9:50 am

Check your /etc/passwd and look for the root user line, and verify root has a proper shell
User avatar
bud77
Knowledgeable
Knowledgeable
 
Posts: 374
Joined: Tue Mar 06, 2012 3:23 pm
Location: France

Re: Root access by SSH denied

Postby Nulkoud » Thu Mar 08, 2012 10:07 am

Ah, thanks!

root has a shell in the path /opt, but /opt wasn't existing anymore after the update.

thanks a lot!
Nulkoud
I'm New!
I'm New!
 
Posts: 8
Joined: Fri Sep 24, 2010 4:22 pm

Re: Root access by SSH denied

Postby bud77 » Thu Mar 08, 2012 10:13 am

You're welcome :)

If I remember correctly, it should be a /bin/ash for root
User avatar
bud77
Knowledgeable
Knowledgeable
 
Posts: 374
Joined: Tue Mar 06, 2012 3:23 pm
Location: France

Re: Root access by SSH denied

Postby Nulkoud » Thu Mar 08, 2012 10:18 am

That's correct, it was /opt/bin/bash beacuse of some modifications I did. I just forgot that the /opt dir is always missing after a firmware update.
Nulkoud
I'm New!
I'm New!
 
Posts: 8
Joined: Fri Sep 24, 2010 4:22 pm

Re: Root access by SSH denied

Postby maxxfi » Thu Mar 08, 2012 11:36 am

EDIT: what I described below is NOT SAFE on a Synology NAS.
maxxfi wrote:Instead of mangling with /etc/passwd file, add as last line of root's .profile something like:
exec /opt/bin/bash
That will launch bash (closing default ash) when you login in, but only if it finds it.
So after an update (or more generally if /opt gets broken) you can still login as root.


Instead, this is a safer way to do it:
Code: Select all
if [ -x /opt/bin/bash ]; then
  exec /opt/bin/bash
fi
Last edited by maxxfi on Sun Apr 15, 2012 3:51 pm, edited 1 time in total.
DS-411 (DSM 4.2-3202) w/ 2x WD10EFRX + 1x HD154UI
DS-106j (DSM 3.0-1357), PATA-to-SATA adapter, 2.5" HM250HI
User avatar
maxxfi
Architect
Architect
 
Posts: 4334
Joined: Sun Dec 27, 2009 12:13 pm
Location: Espoo, Finland

Re: Root access by SSH denied

Postby Nulkoud » Thu Mar 08, 2012 11:43 am

I understand what you mean, but I don't know how this works.
Am I right that the 'profile' file is a kind of script which will be called after login?
Is it true that when I edit the profile like you sad, there will be a bash opened into another bash or do you mean that it will close the default (b)ash?
Nulkoud
I'm New!
I'm New!
 
Posts: 8
Joined: Fri Sep 24, 2010 4:22 pm

Re: Root access by SSH denied

Postby maxxfi » Thu Mar 08, 2012 1:42 pm

Yes, .profile is a "configuration" file that is automatically run by any sh/ash/bash, typically to set a few variables and user customization.
When you have something like "exec <command>" the current shell (in this case, ash) launches <command> and terminate itself, freeing memory and resources.
DS-411 (DSM 4.2-3202) w/ 2x WD10EFRX + 1x HD154UI
DS-106j (DSM 3.0-1357), PATA-to-SATA adapter, 2.5" HM250HI
User avatar
maxxfi
Architect
Architect
 
Posts: 4334
Joined: Sun Dec 27, 2009 12:13 pm
Location: Espoo, Finland

Re: Root access by SSH denied

Postby judge146 » Sun Apr 15, 2012 9:36 am

Hi maxxfi,

I added the line exec /opt/bin/bash to the .profile file of the root-user. However, now I am unable to login as root anymore. The error message "-ash: exec: line 22: /opt/bin/bash: not found" is displayed in the terminal window and the session is ended. Can you please help me out?
judge146
I'm New!
I'm New!
 
Posts: 1
Joined: Sun Apr 15, 2012 9:32 am

Re: Root access by SSH denied

Postby maxxfi » Sun Apr 15, 2012 3:45 pm

judge146 wrote:I added the line exec /opt/bin/bash to the .profile file of the root-user. However, now I am unable to login as root anymore. The error message "-ash: exec: line 22: /opt/bin/bash: not found" is displayed in the terminal window and the session is ended. Can you please help me out?


Hmm... it seems that you don't have /opt/bin/bash available.
I was surprised that the 'exec' instruction did not stop when it detected that the command was not existing. I tested with my DS and it is unfortunately true: normally on a sane Linux distro exec would avoid to exit the current shell if the command request fails:
bash: /opt/bin/notexistingshell: No such file or directory
Connection closed by foreign host.

but Synology is using busybox, and it seems busybox doesn't implement this safety net.

I'm very sorry for the issue. I'll try to come up with some trick in order to recover the situation.
BTW, could you please tell me which model of DS do you have?
DS-411 (DSM 4.2-3202) w/ 2x WD10EFRX + 1x HD154UI
DS-106j (DSM 3.0-1357), PATA-to-SATA adapter, 2.5" HM250HI
User avatar
maxxfi
Architect
Architect
 
Posts: 4334
Joined: Sun Dec 27, 2009 12:13 pm
Location: Espoo, Finland

Re: Root access by SSH denied

Postby scientastic » Thu Jul 19, 2012 3:32 am

I have a similar issue. I upgraded/migrated from a DiskStation 212+ to a 712+, but forgot that the architecture is dissimilar. Now /opt/bin/bash won't run because it's the wrong architecture. So... my quandary is that I can't log in to edit /etc/passwd, and I need to edit /etc/passwd to enable login.

Any idea how to get around this? Any idea how to access the root filesystem without telnet or SSH access?

Thanks!
scientastic
I'm New!
I'm New!
 
Posts: 2
Joined: Thu Jul 19, 2012 3:29 am

Re: Root access by SSH denied

Postby memento » Tue Jul 24, 2012 7:57 am

So... my quandary is that I can't log in to edit /etc/passwd, and I need to edit /etc/passwd to enable login.

I'm in the same boat right now. Any tips on how to resolve this? Can I boot the box from a thumbdrive?
memento
I'm New!
I'm New!
 
Posts: 2
Joined: Sat Mar 26, 2011 11:00 pm

Re: Root access by SSH denied

Postby Jeankrill » Thu Aug 16, 2012 9:34 pm

I did the same, messed up the /root/.profile and then could not log in as root anymore over SSH and the web DSM did not work at all.

So I logged in as 'admin' and that worked fine, but I did not have the rights to change /root/.profile, so I required root access by running the 'su' command:

Diskstation>su root

it asked for a password and my old root password did not work anymore, but I tried with the default synology root password 'synopass' and it worked.

Then I went on and corrected my mistakes in /root/.profile and now everything works like a charm.

I'm a linux noob, but I hope this works for you guys too.
Jeankrill
I'm New!
I'm New!
 
Posts: 1
Joined: Thu Aug 16, 2012 9:20 pm

Next

Return to IPKG

Who is online

Users browsing this forum: No registered users and 0 guests