DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2011-03-31 21:24:46

fmackenz
Member
Registered: 2011-03-31
Posts: 11

Help editing sshd_config

Hello,

I finally decided to funplug my NAS.  FYI, I'm a complete newb to Linux, but I managed to successfully install Fonz fun_plug 0.5 on to my DNS-323. 

Much to my delight, I have OpenSSH on port 22 working (and I've disabled telnet).  However, I'd like to change the SSH port to 443.  I understand it should be a simple edit and I managed to navigate to the directory containing the sshd_config file, however I can't figure out how to edit it. 

I've tried using various text editors from a windows machine.  I tried using "vi sshd_config" but "vi" doesn't seem to be a recognized command.  Do I need to be in a specific directory to use "vi"?

Any help on this would be appreciated.  Thanks.

Last edited by fmackenz (2011-03-31 21:25:03)

Offline

 

#2 2011-03-31 21:36:53

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Help editing sshd_config

vi should be installed as part of the default implementation which includes busybox. Assuming that the install went correctly, then your path should be set automatically to include /ffp/bin which is where you should find vi.


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#3 2011-03-31 22:09:39

bjby
Member
Registered: 2009-02-22
Posts: 265

Re: Help editing sshd_config

download and install joe from fonz packages using funpkg. joe (joe's own editor, which is a fantastic name) is easy to use. vi and all its clones seems supereffective ones youre bent badly, but for mortals its close to useless.

Offline

 

#4 2011-03-31 22:39:07

fmackenz
Member
Registered: 2011-03-31
Posts: 11

Re: Help editing sshd_config

Thanks.  I'll install the fonz packages tonight. 

I see that it has joe and nano, which both look much better than vi.  Any idea if I need to change the permissions on sshd_config before I can edit it?

Offline

 

#5 2011-03-31 22:43:16

dhub
Member
Registered: 2011-01-01
Posts: 112

Re: Help editing sshd_config

Be careful changing permissions on the sshd_config file.  The sshd process checks file permissions and won't start if they are to open.

A better option would to make sure you are logged in as the root user when editing the sshd conf file.

Offline

 

#6 2011-04-01 04:03:37

bound4h
Member
Registered: 2010-04-12
Posts: 209

Re: Help editing sshd_config

Just change the external port forwarding on your router's gateway page.  Set it to forward external port 443 to internal port 22 on the ip of your NAS.  Should be in the Port Forwarding section of your router gateway page.  MUCH easier than messing with sshd_config and accomplishes the same thing.

Poster your router model if you want some help.

Offline

 

#7 2011-04-01 16:15:33

fmackenz
Member
Registered: 2011-03-31
Posts: 11

Re: Help editing sshd_config

I still can't get OpenSSH working on port 443.  Here's what I have tried:

Changed the line in /ffp/etc/ssh/sshd_config from:

#Port 22
to:
Port 443

Restarted OpenSSH with: sh /ffp/start/sshd.sh restart

Got booted from the SSH session. smile  Tried to reconnect with port 443, no dice.  port 22, no dice.  And I have telnet disabled. Ugh!  So, I removed everything and started over again.  Now I have telnet up and working and this time I changed sshd_config before the first start.  Tried to SSH connect with Putty to port 443, no dice.  22, no dice.

Tried: sh /ffp/start/sshd.sh -p 443, was told that I could only use start/stop/restart/status
Checked:  sh /ffp/start/sshd.sh status, sshd is not running?  Tried to start, but can't seem to start it.

Changed Port 443 to #Port 443.  sh /ffp/start/sshd.sh start, fires right up.  Use putty, connects via Port 22 no problem.

Go back, stop the service, change #Port 443 to Port 443.  Start the service.  Check status and it's not running.

Long story short:  When I try to specify Port 443 in sshd_config, I can't start the sshd service.  However when I comment out #Port it runs fine.  What am I doing wrong?

Checked my router to see if I could forward external port 443 to internal port 22.  It wasn't obvious to me how that could be done on my Netgear WNDR3300.

Offline

 

#8 2011-04-01 18:37:15

karlrado
Member
Registered: 2009-12-07
Posts: 229

Re: Help editing sshd_config

Port 443 is often used for HTTPS.  If you have a web server running on the NAS, and you probably do, you may be getting a port conflict.

You can try starting sshd with debugging level and message options set so that you can see messages and see if this is the problem.  Do a web search for sshd man pages to learn how.

Or, try some other port number.  Something like 6211.

If you make this work, then each time you ssh to the NAS on your local network, you'll have to specify the non-default port number.  This can be automated through the use of config files, depending on your ssh client.

If you want to ssh to your NAS from outside your network, you'll have to forward the port to your NAS IP address at port 6211, if that is what you picked above.  You could set the incoming port to 22.  But it would be better to pick another port (6211 is ok) so that you don't get as many break-in attempts from port scanners.


DNS-323 FW 1.07 : 2 1TB WD Caviar Green SATA : fun_plug: utelnet + optware (no ffp)

Offline

 

#9 2011-04-02 03:03:53

bound4h
Member
Registered: 2010-04-12
Posts: 209

Re: Help editing sshd_config

karlrado wrote:

But it would be better to pick another port (6211 is ok) so that you don't get as many break-in attempts from port scanners.

Take heed!  I had SSH on port 22 with at least 5 break-in attempts DAILY.  Changed to a random port and not a single one.  Doesn't mean you're invisible but it does mean you're not part of the 200 million computer users with default SSH ports.

Offline

 

#10 2011-04-02 03:29:10

fmackenz
Member
Registered: 2011-03-31
Posts: 11

Re: Help editing sshd_config

Right.  Until I have it figured out I've disabled port forwarding on my router.

Still can't get OpenSSH to use port 443.

netstat -an | grep 443 returned:
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN

lsof -i :443 returned:
COMMAND  PID USER   FD   TYPE DEVICE SIZE NODE NAME
webs        1600 root    4u   IPv4   1645           TCP    *:443 (LISTEN)

I'm not running a webserver.  All I have installed is the fonz fun plug.

Offline

 

#11 2011-04-02 03:41:01

fmackenz
Member
Registered: 2011-03-31
Posts: 11

Re: Help editing sshd_config

ps aux | less turned up

1600 root     /web/webs

Then in directory /web I found:
lrwxrwxrwx    1 root     root           18 Apr  1 13:58 webs -> /sys/crfs/web/webs

Anyone have any idea what this is or where it came from?

Offline

 

#12 2011-04-02 04:42:04

dhub
Member
Registered: 2011-01-01
Posts: 112

Re: Help editing sshd_config

When running ffp the dlink web interface is still running on ports 80/443.  It's the process named /webwebs

Offline

 

#13 2011-04-02 04:42:35

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Help editing sshd_config

webs is the DLink administration program. It will restart automatically if you don't get rid of all the associated processes. Check out the kickwebs.sh script in /ffp/start (I believe it is part of the default install, if not, then google it).


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#14 2011-04-02 05:39:19

fmackenz
Member
Registered: 2011-03-31
Posts: 11

Re: Help editing sshd_config

Genius. 

That fixed the problem.  It should probably be noted on the OpenSSH config page that you need to:

chmod a+x /ffp/start/kickwebs.sh

Thanks for all the help.

Offline

 

#15 2011-04-02 06:11:48

fmackenz
Member
Registered: 2011-03-31
Posts: 11

Re: Help editing sshd_config

Bah.  I rebooted the DNS - 323 and now I can't access SSH again.

I got it to work by executing:

sh /ffp/start/kickwebs.sh start
sh /ffp/start/sshd.sh start

But it doesn't seem to work after a reboot.

Tips on re-enabling telnet now?

Offline

 

#16 2011-04-02 07:48:05

fmackenz
Member
Registered: 2011-03-31
Posts: 11

Re: Help editing sshd_config

Got telnet working.  Got SSH on port 443 working, but had to manually execute kickwebs before sshd.

How do I ensure that kickwebs starts up before sshd on a reboot?

Offline

 

#17 2011-04-02 14:29:57

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Help editing sshd_config

Lots of options.....

You could 'kick' it from /ffp/etc/fun_plug.local
You could modify your SSH script to call kickwebs
You could modify your SSH script to kill webs using ps, grep, kill etc

I believe there is a way to set the order as it is dependant on 'rcorder', but I do not recall off the top of my head how to do it.

Last edited by FunFiler (2011-04-02 14:55:09)


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#18 2011-04-03 02:34:13

fmackenz
Member
Registered: 2011-03-31
Posts: 11

Re: Help editing sshd_config

Adding the line:

sh /ffp/start/kickwebs.sh start to sshd.sh worked like a charm.

I also added it to lighttpd.sh just to be safe. [along with changing the port from 8080 to 80]

Thanks.  (I can't be the only person to ever have this issue, can I?)

Last edited by fmackenz (2011-04-03 02:35:56)

Offline

 

#19 2011-04-03 03:14:41

FunFiler
Member
Registered: 2010-05-23
Posts: 577

Re: Help editing sshd_config

Glad I could help.


3 * (DNS-323 with 2 * 2TB) = 12TB Running FW v1.08 & FFP v0.5
Useful Links: Transmission, Transmission Remote, Automatic

Offline

 

#20 2011-04-04 19:51:14

karlrado
Member
Registered: 2009-12-07
Posts: 229

Re: Help editing sshd_config

fmackenz wrote:

Thanks.  (I can't be the only person to ever have this issue, can I?)

I didn't understand why you were wanting to route SSH traffic over port 443 until I searched an bit and found that people sometimes do it to get through firewalls.  So I get it now.

I think that most people trying to achieve the same thing would do it by translating the port number during port forwarding in their router.  And that's why the issue does not come up much.

Although you've got it working now, you still have some nasty hacks in place to disable the admin server.  Someday, you may need it for something.

I would probably leave the SSHD config alone on the NAS, setting back to its defaults.  Then change the router to translate the port number.

You must already have port forwarding in place on your router to direct incoming port 443 to your NAS port 443.  Just change that forwarding so that the incoming port 443 traffic gets routed to your NAS at port 22.  This solution was mentioned earlier and may actually be the better one.  Hopefully your router supports this.  (I think I had some old firmware on a Qwest-provided router once that could only forward port xxx traffic to a local address using the same port xxx).  If your router does not allow the port number to change, then your current solution is probably the only way.


DNS-323 FW 1.07 : 2 1TB WD Caviar Green SATA : fun_plug: utelnet + optware (no ffp)

Offline

 

#21 2011-04-06 21:09:54

fmackenz
Member
Registered: 2011-03-31
Posts: 11

Re: Help editing sshd_config

I have the admin server running on port:81, so it really isn't much of an issue.

I briefly scanned the port forwarding function on my router and didn't see how I could use port forwarding to remap incoming port 443 to 22.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB