43

I've been doing my google-fu, but I can only find outdated guides or guides pertaining solely to the server variations of Ubuntu.

I need to set it up so that ssh server is run on boot, so I can access the computer remotely without having to first physically log in on the host computer. How would I do that? I already have ssh server set up so that I can log in and all that, but first I would have to log in on the host and run sudo /etc/init.d/ssh start

4
  • 1
    Are you on wireless? Sep 9, 2010 at 13:17
  • 1
    I am on wireless, yes. Sep 9, 2010 at 13:33
  • 3
    I think you should right click on the connection icon, select Edit Connections, click on the Wireless tab, double-click your wireless connection and mark both "Connect automatically" and "available to all users". That means your connection will be up and running without logging in graphically. Sep 9, 2010 at 13:56
  • How would you need the SSH to work? If you simply want the connection active in the background, it's quite easy, but if you want the SSH shell to appear whenever you login, it's a different solution.
    – Oxwivi
    Jun 18, 2011 at 9:27

3 Answers 3

50

This should do the trick..

sudo update-rc.d ssh defaults

EDIT: If your network is configured with Network Manager then the connection will not be established until a user logs in through the GUI. For manually configuring you have to edit the /etc/network/interfaces file, have a look at this guide and if you use wireless you can have a look here

7
  • I am on a wireless network. That question you linked to last suggested that all I would need to do was to enable the connection for all users. Is that the case? Sep 9, 2010 at 13:36
  • I linked incorrectly, the link is now fixed and additional you can look at this: ubuntuforums.org/showthread.php?t=263136 Sep 9, 2010 at 14:24
  • What is it about this command sudo update-rc.d ssh defaults that should resolve the problem? In other words, what does this command do? Jul 11, 2014 at 16:52
  • 1
    @HairOfTheDog it sets the ssh server to start at default runlevels... Jul 12, 2014 at 17:02
  • 1
    Maybe try to figure out what a command does before just blindly running it! But I don't think this problem have anything to do with update-rc.d. You should perhaps take a look at your ssh server configuration, it is located in /etc/ssh/sshd_config and the logfiles located in /var/log/ folder. If you want information about the update-rc.d command you can look at its manual page by running man update-rc.d Apr 14, 2015 at 10:30
22
sudo update-rc.d ssh defaults

will work on sysV systems, but the newest ubuntu uses systemd to control the boot process. In order to get sshd to start on boot for a systemd system, you need to

systemctl enable ssh.socket

as root.

3
  • 1
    this solve my problem.. that after boot service need a restart to ssh service to make it active.
    – onalbi
    Jul 19, 2016 at 12:36
  • This answer should be expanded. I am not sure, or I would edit myself, but I believe that Kernelsanders refers to "sudo update-rc.d ssh defaults" when he says "This will work on sysV systems". The exact reference should be specified, not left for the reader to guess at a meaning. Otherwise, I believe this answer should be the "correct" answer.
    – Mark G B
    Sep 28, 2017 at 2:01
  • Corvus is right. Edited. Sep 28, 2017 at 19:15
1

If you install the openssh server from the repository it should start on boot by default, regardless of having a network connection available or not (which is a different issue for which mot people is responding).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .