how to use sshpass to a different port number

611 views Asked by At

I am trying to use sshpass with port number.

sshpass -p "somepassword" scp [email protected]/somefile /somefolder

how to pass port number to sshpass ?

1

There are 1 answers

0
hamzaouni On BEST ANSWER

To use sshpass with a port number, you can specify the port using the -P option. Here's how you can modify your command:

sshpass -p "somepassword" scp -P <port_number> [email protected]:/somefile /somefolder

Replace <port_number> with the actual port number you want to use. For example, if the port number is 2222, the command would be:

sshpass -p "somepassword" scp -P 2222 [email protected]:/somefile /somefolder

This will allow you to use sshpass with a specific port number for SCP. The -P option in scp is used to specify the port number, and it is different from the -p option in sshpass. The -P option in scp is case-sensitive and should be in uppercase. The default SSH port is 22, but you can specify a different port using the -P option in scp when using sshpass