systemd-thoughts

This commit is contained in:
user 2022-01-17 08:33:46 +01:00
parent 24bbe2a367
commit e92e69e151
2 changed files with 54 additions and 16 deletions

View File

@ -0,0 +1,37 @@
# systemd cheat sheet
## ssh systemd rerverse shell as service
- persistent reverse SSH connection with systemd
```
-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

View File

@ -1,18 +1,19 @@
# systemd cheat sheet
## systemd- bootdelay analyzing
Short summarize over boot duration
system-analyze
Generate plot for systemd boot process
system-analyze plot > boot.svg
firefox boot.svg
kernel log with delta in time
dmesg --show-delta --color=always | less -R
correlate initramfs with kernel messages
journalctl -b -o short-monotonic
sort systemd load times
systemd-analyze blame
select specific initramfs service
journalctl -b -o short-monotonic -u systemd-udev-settle.service
analyse with systemd-bootchart
init=/lib/systemd/systemd-bootchart
the chart file is located under /run/log/bootchart
- Short summarize over boot duration
`system-analyze`
- Generate plot for systemd boot process
`system-analyze plot > boot.svg`
`firefox boot.svg`
- kernel log with delta in time
`dmesg --show-delta --color=always | less -R`
-correlate initramfs with kernel messages
`journalctl -b -o short-monotonic`
- sort systemd load times
`systemd-analyze blame`
-select specific initramfs service
`journalctl -b -o short-monotonic -u systemd-udev-settle.service`
- analyse with systemd-bootchart
`init=/lib/systemd/systemd-bootchart`
- the chart file is located under `/run/log/bootchart`