Skip to content

SCP

scp can both push or pull files: scp SOURCE DESTINATION

Example 1: Pull a file from a remote Linux box to a Windows PC

Section titled “Example 1: Pull a file from a remote Linux box to a Windows PC”
Terminal window
scp {{user}}@{{remote-host}}:/home/{{user}}/logs.zip C:\Users\{{user}}\Desktop\

Example 2: Push a file from local pc to remote Linux box:

Section titled “Example 2: Push a file from local pc to remote Linux box:”
Terminal window
scp foo.zip {{user}}@{{remote-host}}:/tmp

Example 3: Using sshpass to provide the password to scp if not using ssh keys

Section titled “Example 3: Using sshpass to provide the password to scp if not using ssh keys”
  • -r recursively copy all files in a directory
Terminal window
sshpass -p "ssh_password" scp -r local_dir/ user@host:/home/user/