section77 Wiki

2023.10.07 SSH Tricks

SSH Tricks

ssh-config

keyfiles sind toller als passwörter

security keys sind noch sicherer als keyfiles und passwörter

hosts hinter nats

bestehende ssh-verbindung ändern

auf dateien zugreifen

Remote Packet Capture & View in Wireshark

ssh root@remoteserver 'tcpdump -c 1000 -nn -w - not port 22' | wireshark -k -i -

Run Command Remotely (non-interactive)

ssh remoteserver "cat /var/log/nginx/access.log" | grep badstuff.php

SSH Copy Folder from Local to Remote

tar -cvj /datafolder | ssh remoteserver "tar -xj -C /datafolder"

Copy remote folder to local tar archive

ssh user@remoteserver "tar -jcf - /path/to/backup" > dir.tar.bz2

Remote GUI Applications with SSH x11 Forwarding

ssh -X remoteserver vmware

Copy files remotely with rsync and SSH

rsync -az /home/testuser/data remoteserver:backup/

SSH over Tor Network

torsocks ssh myuntracableuser@remoteserver

Edit text files with VIM over ssh/scp

vim scp://user@remoteserver//etc/hosts

Mount remote SSH location as local folder with SSHFS

sshfs user@remoteserver:/media/data ~/data

SSH Multiplex using ControlPath

Host remoteserver
HostName remoteserver.example.org
ControlMaster auto
ControlPath ~/.ssh/control/%r@%h:%p
ControlPersist 10m

Bouncing through jump hosts with ssh and -J

ssh -J host1,host2,host3 user@host4.internal

Modify Port Forwarding within a session with ~C

~C

Speed Test

yes | pv | ssh <remote_host> "cat >/dev/null"

SSH auf Windows nutzen