How to use sshpass with scp over proxy jump

In this scenario we need to get some files from server B through using server A as a proxy jump, and additionally we need to pass the password on the command line using sshpass, the password is common for both servers A and B, to achieve this we used the following command:

$ sshpass -p password scp -r -J username@A username@B:/path/to_get/files/* .


  • sshpass -p: is used to pass the password in a non-interactive way
  • -r: means get files recursively from source
  • -J: the server to use as proxy jump host
  • .: the destination to copy the files to the local server

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store