ssh:override_socket-activated_ssh
Differences
This shows you the differences between two versions of the page.
ssh:override_socket-activated_ssh [2016/10/17 14:54] – created peter | ssh:override_socket-activated_ssh [2019/12/04 21:26] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== SSH - Override socket-activated SSH ====== | ||
- | |||
- | ===== Override socket-activated SSH ===== | ||
- | |||
- | Occasionally when systemd gets into a broken state, socket activation doesn’t work, which can make a system inaccessible if ssh is the only option. This can be avoided configuring a permanently active SSH daemon that forks for each incoming connection. | ||
- | |||
- | To do this directly on the CoreOS machine, begin by replacing the default sshd unit file at **/ | ||
- | |||
- | <file bash / | ||
- | # / | ||
- | [Unit] | ||
- | Description=OpenSSH server daemon | ||
- | |||
- | [Service] | ||
- | Type=forking | ||
- | PIDFile=/ | ||
- | ExecStart=/ | ||
- | ExecReload=/ | ||
- | KillMode=process | ||
- | Restart=on-failure | ||
- | RestartSec=30s | ||
- | |||
- | [Install] | ||
- | WantedBy=multi-user.target | ||
- | </ | ||
- | |||
- | Next mask the systemd.socket unit: | ||
- | |||
- | <code bash> | ||
- | systemctl mask --now sshd.socket | ||
- | </ | ||
- | |||
- | Finally, execute a daemon-reload, | ||
- | |||
- | <code bash> | ||
- | systemctl daemon-reload | ||
- | systemctl restart sshd.service | ||
- | </ | ||
- | |||
- | The same configuration can be achieved and an actively listening sshd started by providing user-data like: | ||
- | |||
- | cloud-config: | ||
- | |||
- | <file bash> | ||
- | # | ||
- | |||
- | coreos: | ||
- | units: | ||
- | - name: sshd.socket | ||
- | command: stop | ||
- | mask: true | ||
- | |||
- | - name: sshd.service | ||
- | command: start | ||
- | content: | | ||
- | [Unit] | ||
- | Description=OpenSSH server daemon | ||
- | |||
- | [Service] | ||
- | Type=forking | ||
- | PIDFile=/ | ||
- | ExecStart=/ | ||
- | ExecReload=/ | ||
- | KillMode=process | ||
- | Restart=on-failure | ||
- | RestartSec=30s | ||
- | |||
- | [Install] | ||
- | WantedBy=multi-user.target | ||
- | |||
- | write_files: | ||
- | - path: "/ | ||
- | permissions: | ||
- | owner: " | ||
- | </ | ||
- | |||
- | | ||
- | Ignition: | ||
- | |||
- | <file bash> | ||
- | { | ||
- | " | ||
- | " | ||
- | }, | ||
- | " | ||
- | " | ||
- | { | ||
- | " | ||
- | " | ||
- | }, | ||
- | { | ||
- | " | ||
- | " | ||
- | " | ||
- | } | ||
- | ] | ||
- | } | ||
- | } | ||
- | </ | ||
ssh/override_socket-activated_ssh.1476716098.txt.gz · Last modified: 2020/07/15 09:30 (external edit)