Questions tagged [scp]

SCP (Secure Copy) is a secure protocol based on SSH used for transferring files between computers.

The SCP protocol is basically identical to the BSD rcp protocol. Unlike rcp, data is encrypted during transfer to prevent potential sniffers could extract information from the packets. However, the protocol itself provides no authentication or security, it depends on the protocol below it, SSH to do it.

SCP only implements the file transfer. He does this by connecting to the host using SSH and SCP there running a server (scp). The program of the SCP server is usually the exact same program as the SCP client.

To perform a file upload, the client provides the server files to be uploaded(you can optionally include your basic attributes, such as its access permissions). To download the file, the client sends a request for files or directories to be downloaded. When you are downloading a directory, the server provides the client with its sub-directories and files. So the download is "server-oriented", which poses a security risk when it is connected to a malicious server.

734 questions
138
votes
6 answers

scp files via intermediate host

I have access to 3 machines, A, B, and C. The only possible (ssh) connections are: A -> B B <-> C I need to get files from A to C, so I could scp the files from A to B, and then scp them from B to C. However, B doesn't have much disk space, so this…
astrofrog
  • 1,767
67
votes
13 answers

Scp over a proxy with one command from local machine?

I have my local.machine, the proxy.machine and target.machine. local.machine doesn't have direct contact with target.machine, but needs to go through proxy.machine. I want to scp a file from target.machine to local.machine. Is this possible to do…
grm
  • 2,554
66
votes
10 answers

How do I scp the (huge) output of a command directly to a remote machine?

Note that I can't first store the file locally -- it's too big. This (obnoxious) page (scroll all the way to the bottom) seems to give an answer but I'm having trouble disentangling the part that's specific to tape…
dreeves
  • 1,033
38
votes
4 answers

scp -r ... but leave out (exclude) a specified subdirectory

Here's the directory structure: /a/ /a/b/ /a/c/ I want to copy everything, EXCEPT for the /a/c/ subdirectory. scp -rp myserver:/a . # this will copy everything Q: How would I specify a directory to leave out in the scp command ?
19
votes
3 answers

Scp the current dir `.` to another name

This is an edge use case, but I can't find a solution. I want to copy the current directory ., without necessarily knowing or caring for its name, to a new directory. Using scp. Bash does not seem to have a problem. e.g. cp -r . ../new-name will…
gcb
  • 4,891
  • 11
  • 56
  • 75
12
votes
5 answers

Copying remote file to a specified path on local desktop using scp

I was trying to copy a file from remote server using SCP but its giving the following error. bash-3.2$ scp username@server:main.php C:\main.php ssh: Could not resolve hostname C: hostname nor servname provided, or not known Its assuming C: as…
12
votes
1 answer

Can I make scp ask before overwriting an existing file?

Is there a possibility (man scp didn't reveal any) to make scp interactive like cp -i? That is, scp asks, if the target exists, if it may overwrite it? If yes, does it work locally and remote? If no: Let's alias it! But I hope for a simpler…
Boldewyn
  • 4,388
10
votes
2 answers

Is it possible with SCP to only copy files that match a certain date?

Is it possible to have SCP filter the files that it copies by date, e.g., if you wanted to copy all files that were created on 12/29 and ignore the others?
eichoa3I
  • 1,522
6
votes
1 answer

Why do you need to escape spaces when passing SCP filenames?

Anyone who's ever SCP'd knows that this probably doesn't work: scp foo.txt 'me@remote.net:foo bar.txt' For me on this one, I get: "ambiguous target". The man page for SCP doesn't explain why you need to escape that space, yet the argument seems to…
Thanatos
  • 2,492
5
votes
3 answers

SCP giving out a blank line and not transfering files

As said, an image is worth a thousand words: This blank line is weird. SSH works correctly. Some verbose mode shows me this: I just... scp never gave up on me. Looks like it did today.
4
votes
1 answer

`scp` searches for target alias on source host instead of local machine

When I try to copy files between two hosts, of which the second is identified by an alias: scp host:foo alias: scp tries to resolve alias by looking into host:.ssh/config and not my local ~/.ssh/config -- in other words, as if I've ssh-ed to host…
Irfy
  • 257
4
votes
7 answers

Is there a way to tell if a file is done copying?

The scenario is this: Machine A has files I want to copy to Machine C. Machine A can't access C directly, but can access Machine B that can access Machine C. I am using scp to copy from Machine A to B, and then from B to C. Machine B has limited…
Mike Cooper
  • 2,206
3
votes
1 answer

copy files from one remote machine to another

I work at a university, and we have a remote machine(1) that I ssh into. To do this from my laptop, I believe that I have to first ssh into the university system and then ssh into the particular machine. This all happens automatically for me because…
3
votes
3 answers

Information to the snippet: "scp user@hostb:file user@hostc:"

Suppose you have root access in an unknown server. You want to copy a file from the server to your local machine. Source of the snippet in the title. Challenge: copy to a file from the unknown server, where you have root rights, to your local…
user3672
2
votes
1 answer

Skipping a file from downloading using scp

Just a simple question. Say I have a bunch of *.txt files on a server somewhere and I'm using the standard scp command to download *.txt to my computer. However, say one of the files, call it "bad.txt" is extremely large and happens to be a file I…
Amit
  • 441
  • 1
  • 6
  • 14
1
2 3