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?
 
Failed to enable unit: Refusing to operate on linked unit file sshd.service
 
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.
 
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
 
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
 
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
 
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
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!
 
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
 
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!
 
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
Apologies for the bump, but I'm having this problem with the debian-10-standard_10.5-1_amd64.tar.gz image. The solution posted by xbishop did not help unfortunately. has anyone had this issue since and been able to resolve it?
 
  • Like
Reactions: lps90
yeah, for the first time this is happening to me with Proxmox 7 + Debian 10.7 lxc container.
With FailOver ips it works, but when using the default machine public ip is not working.
If i restart the lxc container ssh in webgui, it starts working, but only works until the next lxc container restart.
any possible solution?
 
Having the same issue here. SSH won't start on a brand new Ubuntu 20.04 LXC container. I also tried a Ubuntu 18.04 container, as well as a 20.04 privileged container, all having the same issue.

Host info:
Code:
pve-manager/7.0-10/d2f465d3 (running kernel: 5.11.22-3-pve)

I can attach to the LXC container from the host and start SSH manually. If I enable the service (systemctl enable ssh) it appears to work, but after a reboot of the LXC, SSH is dead.
Code:
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: inactive (dead)
       Docs: man:sshd(8)
             man:sshd_config(5)
 
Last edited:
  • Like
Reactions: lps90

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, 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 yours easily in our online shop.

Buy now!