Skip to content
SSH SOCKS proxy as a systemd service

SSH SOCKS proxy as a systemd service

Not much to explain – here is an example unit, /etc/systemd/system/ssh-socks-proxy.service:

[Unit]
Description=Socks proxy via SSH
ConditionPathExists=|/usr/bin
After=network.target

[Service]
ExecStart=/usr/bin/ssh -NTC -o ServerAliveInterval=30 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -i <path_to_ssh_priv_key> -D <port_to_listen> user@remote-server.com

# Restart every >2 seconds to avoid StartLimitInterval failure
RestartSec=5
Restart=always

[Install]
WantedBy=multi-user.target

Enable and start it with systemctl enable --now ssh-socks-proxy.

Sources:

Last updated on