Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add phone-home.service #13

Open
itdaniher opened this issue Jan 8, 2015 · 2 comments
Open

add phone-home.service #13

itdaniher opened this issue Jan 8, 2015 · 2 comments

Comments

@itdaniher
Copy link
Member

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 [email protected]

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

[Install]
WantedBy=single-user.target```
@itdaniher
Copy link
Member Author

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 [email protected]"
Type=simple
RestartSec=3
Restart=always

[Install]
WantedBy=multi-user.target

@itdaniher
Copy link
Member Author

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant