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

Tommy Brunn
  • 9,751
  • 1
    Are you on wireless? – Leon Nardella Sep 09 '10 at 13:17
  • 1
    I am on wireless, yes. – Tommy Brunn Sep 09 '10 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. – Leon Nardella Sep 09 '10 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 '11 at 09:27

3 Answers3

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

  • 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? – Tommy Brunn Sep 09 '10 at 13:36
  • I linked incorrectly, the link is now fixed and additional you can look at this: http://ubuntuforums.org/showthread.php?t=263136 – LasseLuttermann Sep 09 '10 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? – HairOfTheDog Jul 11 '14 at 16:52
  • 1
    @HairOfTheDog it sets the ssh server to start at default runlevels... – LasseLuttermann Jul 12 '14 at 17:02
  • This command has made starting ssh not possible.. maybe next time specify exactly what a command does that way for future onlookers we can tell whether or not they will work with the current version or possibly break something such as this. – Aaron Flores Apr 13 '15 at 14:37
  • It starts, but now no one can connect even locally, Thanks for the awesome command which has no description so I have no way in reversing what it caused – Aaron Flores Apr 14 '15 at 02:58
  • 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 – LasseLuttermann Apr 14 '15 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.

  • 1
    this solve my problem.. that after boot service need a restart to ssh service to make it active. – onalbi Jul 19 '16 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 '17 at 02:01
  • Corvus is right. Edited. – KernelSanders Sep 28 '17 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).

João Pinto
  • 17,159