0

I'm having a problem on my remote server (which is in another city) and I can't access it with SSH. I can see that port 80 and 443 is open, but port 22 isn't. I could only assume that sshd didn't start correctly.

I'm now in the system through a rescue disk. Should adding those lines to rc.local

update-rc.d ssh defaults
/etc/init.d/sshd start

get those commands to run at startup? Or is there something else to be done other than adding them?

Thank you.

The Quantum Physicist
  • 712
  • 3
  • 17
  • 34

1 Answers1

1

Yes. In that you use it to process start-up actions.

So in your example you would open your file using:

sudo nano /etc/rc.local

Just above where it says exit; add the line:

/etc/init.d/ssh start

EDIT: Also ensure the open port directed at your server is listed in /etc/ssh/sshd_config

Matthew Williams
  • 4,314
  • 12
  • 26
  • 38
  • 1
    The weird part is that rc.local is completely empty. Is that normal? – The Quantum Physicist Jan 23 '14 at 09:15
  • Rather odd. The file should look something like: http://ubuntuforums.org/showthread.php?t=1049837 sure you opened the right file? – Matthew Williams Jan 23 '14 at 09:29
  • I didn't write the name myself... the terminal completed it for me with tabs... I could double check that I haven't done a mistake in the path. But do you know the default path for rc.local in debian? – The Quantum Physicist Jan 23 '14 at 09:30
  • The file is stored in the etc folder. So sudo nano /etc/rc.local to open it. – Matthew Williams Jan 23 '14 at 09:32
  • Thank you. The problem isn't solved and I'll format the system, so I'm giving you a +1 for helping. – The Quantum Physicist Jan 23 '14 at 09:50
  • Sorry we couldn't resolve it. Hope you get it all sorted. Let me know if you have any additional problems after formatting. Thanks for the 1+ :) – Matthew Williams Jan 23 '14 at 09:55
  • 2
    @TheQuantumPhysicist, `rc.local` on Debian is mostly a leftover from the olden days. Yes, it's executed on boot and you could do whatever you wanted to fix startup of the SSH server but the correct way to do that once you're in a rescue shell is to `chroot` into the system's root FS and then just run `update-rc.d -f ssh defaults` -- then you could just exit the shell and reboot the system (or let it boot normally if that is a rescue shell provided by initramfs). – kostix Jan 23 '14 at 12:02
  • @TheQuantumPhysicist, see [this](http://superuser.com/a/111215/130459) for an example on how you could do that. Note that mounting special filesystems (`proc`, `sys`) and bind-mounting `/dev` before chrooting is not needed for your case -- it's only needed in complicated cases like fixing up the bootloader as it needs to access devices etc. – kostix Jan 23 '14 at 12:06
  • kostix, you really should write that up as an actual answer. – JdeBP Jan 23 '14 at 20:02