⏏︎ / archive / 2022 / SSH-Ports

Ports for ssh, scp, rsync

Date: 2022-01-07

Have to look1 this2 up3 every time4:

Assuming you’re connected to a machine like

ssh user@my.host.server

and want to transfer files afterwards, you’ll likely update your recent command to

scp user@my.host.server:/my/folder/my.file dest/folder


rsync -a user@my.host.server:/my/folder dest/

for copying said files. So far, so good.

When relying on ports, this gets way more complicated due to differing parameter styles for each command which are

# `-p[port]`
ssh -p222 user@my.host.server

# `-P [port]`
scp -P 222 user@my.host.server:/my/folder/my.file dest/folder

# set port on custom remote shell
rsync -a -e "ssh -p222" user@my.host.server:/my/folder/my.file dest/folder

(Note that rsync has more options for defining TCP daemon ports with --port=[PORT] which is probably not what you want)

You’re welcome!

  1. ssh manpage↩︎

  2. scp manpage↩︎

  3. rsync manpage↩︎

  4. Find offline documentation tools on Stackoverflow … or use Dash on Macs and Zeal man docsets on Windows↩︎

© 2020–23 Studio Agenturbüro — contact@studioagenturbuero.comimprint, privacy policy, credits.