ssh at start and cronjobs LXC container

mx738

New Member
Jan 18, 2022
6
0
1
46
Hello,

i have two questions.

I have installed a Turnkey LXC container (Debian 11)
In this container i can't get up the ssh as service durning boot, i have to start it manually.
And i also try to start ssh by a @reboot entry in cron.d. but all entries in the cron.d will not work at all.
Is there something different in the LXC containers?

Bash:
SHELL=/bin/sh

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin


*/5 * * * * root /opt/my_first_script.sh

*   * * * * root /opt/my_second_script.sh


@reboot /etc/init.d/ssh start
 

sterzy

Proxmox Staff Member
Staff member
Feb 1, 2022
213
49
28
Hi,
I have installed a Turnkey LXC container (Debian 11)
In this container i can't get up the ssh as service durning boot, i have to start it manually.
have you tried enabling the ssh service with systemctl enable ssh.service? That should start the service on boot. If that doesn't work can you maybe provide the output of systemctl status ssh.service?
And i also try to start ssh by a @reboot entry in cron.d. but all entries in the cron.d will not work at all.
If cron is not working at all, it might not be running either, what's the output of systemctl status cron and pgrep cron?
 

mx738

New Member
Jan 18, 2022
6
0
1
46
Hi sterzy,

yes i enable the ssh.service.

systemctl status ssh.service:

Code:
* ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-04-28 13:05:55 UTC; 22h ago
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 592 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 593 (sshd)
      Tasks: 1 (limit: 76872)
     Memory: 3.0M
        CPU: 13.241s
     CGroup: /system.slice/ssh.service
             `-593 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

and here the systemctl status cron

Code:
* cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-04-28 13:01:50 UTC; 22h ago
       Docs: man:cron(8)
   Main PID: 113 (cron)
      Tasks: 1 (limit: 76872)
     Memory: 151.2M
        CPU: 2min 51.520s
     CGroup: /system.slice/cron.service
             `-113 /usr/sbin/cron -f



Ok, i found out, i had an error in my Cronjob to start ssh by cron.

That's not working:
@reboot /etc/init.d/ssh start

with this command it start ssh by cron
@reboot root /etc/init.d/ssh start

So the container works now. But it's weird that ssh not starts normaly.
 
Last edited:

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 your own in 60 seconds.

Buy now!