🍄Sysadmin Cheatsheet

Transferring data

Tailscale

Note: does not support directories, only individual files. Make an archive (.tar, .zip, etc.) of the directory first, then send that.

# Sender
tailscale file cp file.txt otherhost:
# Receiver
tailscale file get path/to/dest/

Rsync (SSH)

  • Omit -z when sending binary data, such as video or audio.

  • Omit -e when the remote SSH server runs on port 22

# Push
rsync -az -e "ssh -p port" source.txt user@destination:path/to/dest/dir/
# Pull
rsync -az -e "ssh -p port" user@destination:path/to/dest/dir/ source.txt

Alternatively, specify the user, domain/IP, and port of the remote system in your ~/.ssh/config

Host somehost
    User [username]
    Hostname [IP address or resolvable domain]
    Port [port]

That simplifies the command to just

# Push
rsync -az source.txt somehost:path/to/dest/dir/
# Pull
rsync -az somehost:path/to/dest/dir/ source.txt

Netcat

Encrypted

age
# Recipient
nc -l -p 7000 | age -d | tar -x
# Sender
cat file | age -ep | netcat otherhost 7000
GPG

Note: I do not recommend GPG in general, but I'm fairly certain it's secure enough for this if you don't want to install age

# Recipient
nc -l -p 7000 | gpg -d | tar -x
# Sender
cat file | gpg -c | netcat otherhost 7000

Unencrypted

Note: not recommended over the open internet unless something else provides encryption, such as a VPN

# Receiving side
nc -l -p 7000 | tar -x
# Sending side
cat file | netcat otherhost 7000