NatLee / telepy

A Django-based web application for managing and monitoring the reverse SSH tunnels or jump servers.
MIT License
6 stars 1 forks source link

[FR] new template with `systemd service` #31

Closed NatLee closed 4 months ago

NatLee commented 6 months ago

需要增加一個template是linux系統下的service

/etc/systemd/system/autossh.service

格式可能會長這樣

[Unit]
Description=AutoSSH tunnel service for reverse SSH tunnel
After=network.target

[Service]
User=${local_user}
ExecStart=/usr/bin/autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -p ${reverse_server_ssh_port} -NR '*:${reverse_port}:localhost:${ssh_port}' telepy@${server_domain}

# Restart service after it exits
Restart=always
# Time to sleep before restarting a service
RestartSec=30

[Install]
WantedBy=multi-user.target

但裡面的local_user或許要使用者自行填入?

可能會用到ㄉ

sudo systemctl daemon-reload
sudo systemctl start autossh.service
sudo systemctl enable autossh.service
NatLee commented 5 months ago

好像除了user外,ExecStart可以直接照抄原本的shell script