auto start sshd

den

Member
Feb 19, 2015
64
1
6
HOST: Virtual Environment 5.1-35
template: ubuntu 17.04

after a reboot, sshd isn't auto started on a CT. how do i enable sshd to auto run?
 

den

Member
Feb 19, 2015
64
1
6
Failed to enable unit: Refusing to operate on linked unit file sshd.service
 

fireon

Famous Member
Oct 25, 2010
3,421
253
103
38
Austria/Graz
iteas.at
Is there a special reason that you are using unstable Ubuntu? I'am using here a lot of 16.04LTS without problems. If you are looking for a LXC-Terminalserver, have a look at this Project.
 

den

Member
Feb 19, 2015
64
1
6
okay so im back to using 16.04.
where in this container can i insert some commands to run at startup?

1. my sshd isnt auto starting
Code:
> systemctl enable sshd
Failed to execute operation: Too many levels of symbolic links
Code:
> systemctl start sshd
works

2. im also trying to setup zoneminder. ive got it working, but having trouble starting the servie at start up.
where do i put in commands to be executed at startup?

thanks in advanced
 

johnha

Member
Jan 1, 2018
10
2
8
I have this same issue. Plain vanilla Ubuntu server 16.04 LXC template. It will not start SSHD automatically. I have to pct enter <id> and then service start ssh. Any ideas would be appreciated!

Perhaps there is something in the tea leaves here (broke the link because I can't post links as a new user): on stackoverflow: /questions/31266838/why-does-lxc-fail-to-start-because-of-too-many-levels-of-symbolic-links-but-do
 

fireon

Famous Member
Oct 25, 2010
3,421
253
103
38
Austria/Graz
iteas.at
Hmm, strange. Only an idea. What i do on every PVE is to increase the fs-inotifyuserwatches.
Code:
cat /etc/sysctl.d/pve.conf

...
fs.inotify.max_user_watches=1048576
...
After that a reboot is required
 

johnha

Member
Jan 1, 2018
10
2
8
Thank you, @fireon. I rebuilt my host on a new faster drive and restored my containers and VMs. And sshd starts up without issue. Thank you for your suggestion - I will keep it in mind. I wasn't aware of that limit. :)
 
  • Like
Reactions: fireon

johnha

Member
Jan 1, 2018
10
2
8
OK I started experiencing this again and it appears that a plain vanilla CT works okay, but once I update it, sshd no longer autostarts.

I tested it by creating a brand new container, using the provided/downloadable Ubuntu 16.04 template from the web gui, all default settings except I gave it a public key, and clicked dhcp.

I was able to SSH into the container ok at that point. But then I updated it (apt update ; apt upgrade -y) and then shut it down (shutdown 0). After restart (pct start 199), I wasn't able to ssh into any more. A quick pct enter 199 and then service ssh start, and I was able to ssh into the container again.

My host is a brand new setup from scratch, no customizations except for some mounted drives. pveversion yields:
pve-manager/5.1-41/0b958203 (running kernel: 4.13.13-4-pve)

Oh, and I did set my fs.inotify.max_user_watches to a million (and rebooted host) as kindly suggested by @fireon

This seems quite strange - can anyone else confirm if this is happening to you? Thanks so much!
 

dcsapak

Proxmox Staff Member
Staff member
Feb 1, 2016
4,603
432
103
31
Vienna
I tested it by creating a brand new container, using the provided/downloadable Ubuntu 16.04 template from the web gui, all default settings except I gave it a public key, and clicked dhcp.

I was able to SSH into the container ok at that point. But then I updated it (apt update ; apt upgrade -y) and then shut it down (shutdown 0). After restart (pct start 199), I wasn't able to ssh into any more. A quick pct enter 199 and then service ssh start, and I was able to ssh into the container again.
tested it here and cannot reproduce this, works without problems

maybe you can get the status of the services before starting, and searching the container journal, to see what fails and/or hangs
 

johnha

Member
Jan 1, 2018
10
2
8
Thank you Dominik for your suggestion. I reviewed the proxmox CT docs again and investigated further using this command: lxc-start -n 102 -F -l DEBUG -o /tmp/lxc-102.log

And sure enough, there are some things that are hanging the boot sequence. I realized I was trying to use SSH too quickly and wasn't waiting long enough for the container to boot.

Thank you Dominik!
 

johnha

Member
Jan 1, 2018
10
2
8

xbishop

New Member
Nov 2, 2018
2
3
3
33
I signed up to post this on both threads. I've had this issue with a local AND datacenter installation of proxmox for testing. SSHD would not start on ubuntu 16.04 after a reboot and the way that I've found to fix this is to:

Code:
sudo nano /etc/systemd/system/network-online.target.wants/networking.service
Change
Code:
TimeoutStartSec=5min
to
Code:
TimeoutStartSec=1sec
Reboot and you have SSH!

Hello future me for when you stress out over this again.

keywords: sshd_server sshd proxmox ubuntu dead inactive halt restart ssh_server systemd
 
  • Like
Reactions: sinowine

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE and Proxmox Mail Gateway. We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!