I need to download a file from a remote server to my local. The SSH is running on a non-standard port and the remote server required a private key to connect to it from local.
I know how to achieve it separately:
For non standard port it is:
scp -P 2222 username@example.com:/backup/file.zip /local/dir
For server using private key it is:
scp -i private_key.pem username@example.com:/backup/file.zip /local/dir
But how can I download a file that require connecting to a non-default port as well as uses pem file (private key file)? Any help would be appreciated.
Thanks
scp -i private_key.pem -P 2222 username@ip_address:/backup/file.zip .
This worked for me.