sudo vim /etc/systemd/system/permanentAutossh.service
========================================
[Unit]
Description=Keeps a tunnel to myOciFreeNat open
After=network-online.target
[Service]
User=<username>
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -q -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -L 4322:127.0.0.1:5432 -i /<ssh_private_key_file_absolute_path> <username>@<ip_address> -p 22
[Install]
WantedBy=multi-user.target
========================================
sudo systemctl daemon-reload
sudo systemctl enable permanentAutossh
sudo systemctl start permanentAutossh
==================
sudo systemctl daemon-reload
sudo systemctl restart permanentAutossh
sudo systemctl status permanentAutossh
======================
sudo systemctl stop permanentAutossh
sudo systemctl disable permanentAutossh
sudo rm /etc/systemd/system/permanentAutossh.service
Comments
Post a Comment
If you have any doubts, please let me know.