Root user disabled in sshd_config

Post Reply
ltei291
Posts: 9
Joined: Mon Nov 05, 2012 12:53 pm

Root user disabled in sshd_config

Post by ltei291 » Tue Nov 20, 2012 9:03 pm

Hi,

I have rooted my LaCie NAS NS2 with custom capsule V7.
By mistake, I have disabled the root account in sshd_config. :oops:
Is there a way to get back to the original situation, e.g getting accessing via ssh?

Thx for the help

Mijzelf
Posts: 6206
Joined: Mon Jun 16, 2008 10:45 am

Re: Root user disabled in sshd_config

Post by Mijzelf » Wed Nov 21, 2012 10:23 am

A factory reset will revert this.

ltei291
Posts: 9
Joined: Mon Nov 05, 2012 12:53 pm

Re: Root user disabled in sshd_config

Post by ltei291 » Wed Nov 21, 2012 10:28 am

Well I did the following yesterday:

- Factory reset
- reinstall the custom capsule to have root again (2.2.8)

But I can still not access ssh via root. It says permissions denied

Any idea what it could be?

Mijzelf
Posts: 6206
Joined: Mon Jun 16, 2008 10:45 am

Re: Root user disabled in sshd_config

Post by Mijzelf » Wed Nov 21, 2012 10:34 am

Are you connecting at port 2222?

ltei291
Posts: 9
Joined: Mon Nov 05, 2012 12:53 pm

Re: Root user disabled in sshd_config

Post by ltei291 » Wed Nov 21, 2012 10:42 am

Hmmm good point,

I am typing using a MAC OS X terminal the following command:

ssh root@nnn.nnn.nnn.nnn (where nnn is the Fixed IP adress of the lan)

Mijzelf
Posts: 6206
Joined: Mon Jun 16, 2008 10:45 am

Re: Root user disabled in sshd_config

Post by Mijzelf » Wed Nov 21, 2012 4:26 pm

In that case it uses port 22. To get port 2222 you should add '-p 2222' (I think. Depends on Steve)

ltei291
Posts: 9
Joined: Mon Nov 05, 2012 12:53 pm

Re: Root user disabled in sshd_config

Post by ltei291 » Fri Nov 23, 2012 10:15 am

OK I have re-installed and can now connect using port 2222.

Additional question:

I want to configure ssh. I noticed that there is no sshd shell available to start or stop sshd. Is there any shell available that I could re-use and put in the etc/init.d folder?


Thx very much for your help.

Mijzelf
Posts: 6206
Joined: Mon Jun 16, 2008 10:45 am

Re: Root user disabled in sshd_config

Post by Mijzelf » Fri Nov 23, 2012 1:11 pm

The box doesn't use sysv init scripts, but initng. You can start and stop services using ngc:

Code: Select all

ngc --stop <servicename>
ngc --start <servicename>
I'm not sure if there is also a restart, (try ngc --help), but of course you could do

Code: Select all

ngc --stop sshd && ngc --start sshd

ltei291
Posts: 9
Joined: Mon Nov 05, 2012 12:53 pm

Re: Root user disabled in sshd_config

Post by ltei291 » Sat Nov 24, 2012 8:41 am

ok I tried the ngc -R to restart and it worked.

When I try to create a new user (adduser) the user is created but when I reboot the NAS , the user is removed automatically.
Do you know how to prevent this behaviour??

Thank you

Mijzelf
Posts: 6206
Joined: Mon Jun 16, 2008 10:45 am

Re: Root user disabled in sshd_config

Post by Mijzelf » Sat Nov 24, 2012 6:38 pm

ltei291 wrote:Do you know how to prevent this behaviour??
No. But I think you can reasonably easy repair this behavior by adding a boot script which adds the users, if they don't exist.
Have a look in /etc/initng. It contains all bootscripts. And there is a file containing all scripts which have to be started.

ltei291
Posts: 9
Joined: Mon Nov 05, 2012 12:53 pm

Re: Root user disabled in sshd_config

Post by ltei291 » Tue Nov 27, 2012 9:41 am

Well I prefer identifying what is causing this behaviour.

My idea is to be able to connect through SSH with a normal user and then when logged in to be able to do s SU and then connect as root if required?

Has anybody done that before on a NS 2?

Thx

Mijzelf
Posts: 6206
Joined: Mon Jun 16, 2008 10:45 am

Re: Root user disabled in sshd_config

Post by Mijzelf » Tue Nov 27, 2012 12:52 pm

ltei291 wrote:I prefer identifying what is causing this behaviour.
Fortunately I can tell you that. Unfortunately it's not a lead to a clean solution. The cause is Unicorn, a process which does all kinds of nasty things with your carefully adjusted files.

andreus
Posts: 134
Joined: Wed Dec 16, 2009 9:57 pm

Re: Root user disabled in sshd_config

Post by andreus » Tue Nov 27, 2012 8:34 pm

without shuting down unicorn you have to add your user and encrypted password to /etc/initng/sshd.i and to so that when ssh service is started it adds the user/password to ssh service on the fly.

ltei291
Posts: 9
Joined: Mon Nov 05, 2012 12:53 pm

Re: Root user disabled in sshd_config

Post by ltei291 » Tue Nov 27, 2012 10:01 pm

Thank you andreus. Do you know how in the sshd.i script I can create the user without messing up the file?

Post Reply