Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to use sshpass to a different port number

I am trying to use sshpass with port number.

sshpass -p "somepassword" scp someuser@12.12.12.12/somefile /somefolder

how to pass port number to sshpass ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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> someuser@12.12.12.12:/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 someuser@12.12.12.12:/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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading