36

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

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

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 9 '10 at 13:36
  • I linked incorrectly, the link is now fixed and additional you can look at this: ubuntuforums.org/showthread.php?t=263136 – LassePoulsen Sep 9 '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... – LassePoulsen 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
15
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. – Corvus B Sep 28 '17 at 2:01
  • Corvus is right. Edited. – KernelSanders Sep 28 '17 at 19:15
0

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).

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.