Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using ssh to connect to a server. I want to upload local files to the server. Usually I do this by opening the 'New File Transfer Window' However, i'd like to just do this from the command prompt.

what is the command to do this?

share|improve this question
    
Please include the operating system you are connecting from. –  einstiien Mar 11 '10 at 16:37

3 Answers 3

up vote 1 down vote accepted

Since you mention the "New File Transfer" window, my guess is that you're using the ssh.com SSH2 client.

SCP2.EXE is the program to copy files over ssh from the command line.

share|improve this answer
    
yes I use ssh2. but why do i need to download scp2.exe. cant I just use the terminal window to transfer files? –  Omnipresent Mar 11 '10 at 16:15
    
That terminal window is open on the server. So any transfers you initiated there would be from that server. It would require a similar SSH server on your side to accept the transfer request. To do something on a terminal, you would need something local, like a command prompt. Then call SCP2.exe, or Putty's pscp.exe. –  Christopher Karel Mar 11 '10 at 16:24

Sometimes for small text files I copy the contents to the clipboard then paste it to cat in the terminal window. E.g.

  1. Copy text
  2. cat > path/to/file
  3. Paste the file (Shift-Inset) works in putty
  4. Type enter if the file doesn't end in one (makes next key stroke work)
  5. Type Ctrl-D to terminate the input stream
share|improve this answer
    
+1 I do too. I doubt this is the answer he wanted but it is sometimes the quickest way for small files and quick edits. –  Richard Holloway Mar 11 '10 at 17:03

You can do this with rsync.

Something like this should suffice:

rsync -av /path/to/Desktop/ server.name:/path/to/destination

The -av tells rsync to 'archive' (maintains permissions, acts recursively, etc) and to be verbose (print transferred filenames).

Note: if you leave a trailing / at the end of 'Desktop', the contents of the Desktop will be transferred. Without the slash, all documents will be transferred into a folder called 'Desktop' on the destination.

share|improve this answer
    
This would address the question (technically) if you included the -e ssh flag to rsync. –  quadruplebucky Mar 11 '10 at 17:38
    
Right, but that isn't necessary with modern versions of rsync. It transfers files over ssh by default. –  snk Mar 11 '10 at 17:46
    
Right you are. I guess I'm showing my age. –  quadruplebucky Mar 11 '10 at 17:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.