2022-02-01 20:34:39 +00:00
|
|
|
---
|
|
|
|
keywords:
|
|
|
|
- IT
|
|
|
|
---
|
2022-01-17 07:33:46 +00:00
|
|
|
# systemd cheat sheet
|
|
|
|
## ssh systemd rerverse shell as service
|
|
|
|
|
2022-01-17 08:22:46 +00:00
|
|
|
- persistent reverse SSH connection with systemd
|
2022-01-17 07:33:46 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
-g Allows remote hosts to connect to local forwarded ports
|
|
|
|
-N Do not execute a remote command
|
|
|
|
-T Disable pseudo-terminal allocation
|
|
|
|
-o Used to give options in the format used in the configuration file (man ssh_config)
|
|
|
|
ServerAliveInterval Interval in seconds to ping the server while connection has been inactive
|
|
|
|
ExitOnForwardFailure Whether to terminate the connection if it cannot set up all requested port forwards
|
|
|
|
-R Forward given remote TCP port (22221) to the local port (22)
|
|
|
|
-v Verbose mode. More v's increase verbosity.
|
|
|
|
```
|
|
|
|
the specific unit file to place under: `/etc/systemd/system/ssh-reverse.service`
|
|
|
|
|
|
|
|
```
|
|
|
|
[Unit]
|
|
|
|
Description=Reverse SSH connection
|
|
|
|
After=network.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=simple
|
|
|
|
ExecStart=/usr/bin/ssh -vvv -g -N -T -o "ServerAliveInterval 10" -o "ExitOnForwardFailure yes" -R 22221:localhost:22 {target_IP}
|
|
|
|
Restart=always
|
|
|
|
RestartSec=5s
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=default.target
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
credits belongs to blog.stigok.com
|