How to pull a file from a server using scp?

You didn't specify any file: you have to add the file (with path) after the colon:

A$ scp <myuserid>@hostB:/absolutepath/file .

or

A$ scp <myuserid>@hostB:relativepath/file .

for a path relative to your home directory.

If you don't specify a different user (i.e., the user on A and B are the same) you don't need the @

A$ scp hostB:/path/file .

$ scp username@remoteip:remote_location_file /location/where/you/save

This only works when you copy file. if you want to copy a directory use

$ scp -r username@remoteip:remote_location_directory /location/where/you/save

Option you may use on your demand

-P port
Specifies the port to connect to on the remote host. Note that this option is written with a capital "P", because -p is already reserved for preserving the times and modes of the file in rcp.

-p
Preserves modification times, access times, and modes from the original file.

-r
Recursively copy entire directories.

-v

Verbose mode. Causes scp and ssh to print debugging messages about their progress. This is helpful in debugging connection, authentication, and configuration problems.


use proper scp path

scp ssh://user@hostname/tmp/foo.txt .

Tags:

Scp