Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scp command to copy files from remote to local host returns error

I need to copy/transfer some files between different machines over the same network. After doing some reading and search, I thought trying out Java's jsch may be a good option. The bitter fact is probably that no good documentation is available for the jsch perhaps. But then there aren't any other options that I know of.

To implement the file transfers, I picked up two machines on the same network, say host1 (server) where in I installed sshd server, is up and running and I am able to connect to it using putty. Second machine, say host2 (client/local). I installed sshd here as well.

Now I tried copying a file 'test.txt' on desktop of host1 (server) to host2 (client) by running following command in putty after connecting to host1 -

scp admin@host1:test.txt /c

But it returns the following error -

'scp' is not recognized as an internal or external command,
operable program or batch file.

What am I doing wrong? I thought to try in putty first and then implement in java. I am working on jsch/ssh for the first time, so any help would be great.

like image 264
anujin Avatar asked Dec 08 '22 17:12

anujin


2 Answers

If you need to scp something from Windows, then why not simply use pscp to achieve this?

You can download it from the PuTTy website.

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

If you want to use it in a Java program, then here is an example: http://www.jcraft.com/jsch/examples/ScpFrom.java.html

like image 160
Charles Boyd Avatar answered Jan 14 '23 06:01

Charles Boyd


You could install git for windows ( http://code.google.com/p/msysgit/ ). Git for windows includes ssh and scp which you can access when using a git bash window.

Then you can use git for source control as well! :-)

like image 44
Keith John Hutchison Avatar answered Jan 14 '23 06:01

Keith John Hutchison