ade-ma / A20Notes

Configuration tidbits and automation experiments for Linux on A20.
1 stars 0 forks source link

add phone-home.service #13

Open itdaniher opened 9 years ago

itdaniher commented 9 years ago

root@debian-22b52:~# cat /etc/systemd/system/phone-home.service

Description=Phone Home Reverse SSH Service
ConditionPathExists=|/usr/bin
After=network.target

[Service]
User=root
ExecStart=/usr/bin/ssh -NTC -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -i /root/.ssh/id_rsa -R 12345:localhost:22 it@itdaniher.com

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

[Install]
WantedBy=single-user.target```
itdaniher commented 9 years ago
Description=Phone Home Reverse SSH Service
ConditionPathExists=|/usr/bin
After=network-online.target
Wants=network-online.target

[Service]
User=root
ExecStart=/bin/bash -c "/usr/bin/ssh -NTC -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -i /root/.ssh/id_rsa -R $(/usr/local/bin/randPort.sh):localhost:22 it@itdaniher.com"
Type=simple
RestartSec=3
Restart=always

[Install]
WantedBy=multi-user.target
itdaniher commented 9 years ago

1 root@debian-1638b ~ # cat /usr/local/bin/randPort.sh

!/bin/bash

mac=$(echo "ibase=16; $(ifconfig eth0 | grep HWaddr | awk -F':' '{print $6 $7}' | tr [:lower:] [:upper:])" | bc) echo $(($mac+10000))