12

How can I copy a file/folder from windows to linux (putty), probably using scp command?

I used scp user@hostname(windows):c:\folder\filname user@hostname(Linux):/folder/filename(destination), but unfotunately I got an error.

Basically, I am trying to copy from windows to Linux. Hope it works whether I am on windows or Linux.

3 Answers 3

24

I don't think this can work in this form, with the backslash \ separators:

scp user@hotname:c:\folder\filname user@hostname:\folder\filename(destination)

First of all, the path separator in Linux is / instead of \, so this would be better:

scp user@hotname:c:\folder\filname user@hostname:/folder/filename

Secondly, your command looks like as if you're running this command on a third PC, on machineC to copy files from machineA to machineB. If this is not the case and you are in fact on machineA copying files to machineB, then this would be better:

scp c:\folder\filname user@hostname:/folder/filename

UPDATE

If you don't have the scp command in Windows, here are a few options:

  • Install Git. Even if you don't use Git, this installer includes an excellent terminal and common *nix commands, and scp too
  • Download PuTTY. You can use pscp.exe instead of scp, the above syntax will work.
  • Install WinSCP. It has scripting features, but if you want to use the command line the previous two options are easier.
Sign up to request clarification or add additional context in comments.

2 Comments

If I do from windows I get 'scp' is not recognized as an internal or external command,operable program or batch file. If I do from Linux to my windows machine then I get "ssh: connect to host <my machine> port 22: Connection refused lost connection" I think I have to use Winscp.
@knm I updated my post, adding some options to get scp
4

In *nix systems, this should work:

# to copy file.ext from remote server to current working directory
# note the dot (.) at the end, which means current directory
$ scp [email protected]:~/desired/folder/file.ext .

# to copy all files in a folder from remote server 
#                                to current directory
# note the dot (.) at the end, which means current directory
$ scp -r [email protected]:~/desired/folder/* .


# copy a folder and all its contents as it is from remote server 
#                                              to current directory
# note the dot (.) at the end, which means current directory
$ scp -r [email protected]:~/dersired/folder .

More information can also be found in this article: scp command syntax

Comments

1

If you want to copy a file from windows to linux using scp you have to Winscp http://www.siteground.com/tutorials/ssh/ssh_winscp.htm this link would be helpful.

Thanks & Regards,
Alok Thaker

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.