SCP Command with Port

To use the scp command with a specific port, you can utilize the -P option followed by the desired port number. This is particularly useful when the SSH service is running on a non-default port. For example, if you want to copy a file from a remote server using port 80, the command would look like this:

scp -P 80 username@remote_host:/path/to/file /local/destination

This command specifies the port number using the -P flag, ensuring that the scp utility connects to the correct port on the remote server.2 Similarly, if you need to recursively copy an entire directory, you can add the -r option:

scp -r -P 80 username@remote_host:/path/to/directory /local/destination

In this case, the -r option enables recursive copying, and the -P option specifies the port number for the SSH connection.5 It's important to note that the -P option must be placed before the remote server address in the command.3

Leo AI generated answer. Please verify critical facts.