LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (https://www.linuxquestions.org/questions/general-10/)
-   -   need to use scp command but with cp command and copy from Windows (https://www.linuxquestions.org/questions/general-10/need-to-use-scp-command-but-with-cp-command-and-copy-from-windows-4175583007/)

gglq000 06-24-2016 02:20 PM

need to use scp command but with cp command and copy from Windows
 
we have been using the cp command with scp options in our environment. For some reason, the use of scp command directly without cp command never worked and did not even pursue.

Basically, used the following cp scp command when copying from one linux system to another linux system:

cp scp://<username>@<ip>/<path> <destination path>
i.e.
cp scp://root@10.123.23.11/root/mystuff .

this works.
However, I am in need to copy from Windows system to current linux system and I am not sure how I can type the source path. Has anyone done it before?

the Windows systems has scp server installed and I can use Winscp in gui mode.


not sure if following work?
cp scp://<username>@<ip>\c:\<path> <destination path>??

michaelk 06-24-2016 05:14 PM

Quote:

cp scp://<username>@<ip>/<path> <destination path>
What distribution/version are you running? Are you running this command from a terminal window or file browser? Since you are copying files from windows to linux WinSCP is sufficient but if you want to run from a command box you can download a program from the PuTTy website called pscp.

Basically the destination is the linux box which needs to run the server and the windows computer is the client. Filezilla is another Windows sftp GUI client

gglq000 06-24-2016 05:22 PM

I am asking about how to copy from windows using command line. Please do not post unrelated stuff and contaminate the thread:


Basically, used the following cp scp command when copying from one linux system to another linux system:

cp scp://<username>@<ip>/<path> <destination path>
i.e.
cp scp://root@10.123.23.11/root/mystuff .

this works.
However, I am in need to copy from Windows system to current linux system and I am not sure how I can type the source path. Has anyone done it before?

michaelk 06-24-2016 05:37 PM

Sorry abut the unrelated stuff. I basically run CentOS and Debian so unless I have some frame of reference "cp scp://<username>@<ip>/<path> <destination path>" does not make sense so I am curious.

You need to use the pscp command line program which works just like the linux scp and can be downloaded from the URL below. Basic usage is:

pscp source user@host:destination

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

gglq000 06-24-2016 07:56 PM

please disregard the talk about pscp, i am not talking about copying taking place from windows. the copying entity is running from linux in which putty will not work. MichaelK appreciate your willingness to help but if you are not getting the problem fully, please do not contribute otherwise it will only cause more confusion.

Moving on, I installed the cygwin on windows machine so that it will be compatible with POSIX like commands and hopefully scp from linux can be used. Once installed, I found out c:\cygwin\tmp directory is treated as /tmp, at least when it runs from cygwin prompt.

Now, from the linux machine, I do following:
cp scp://<username>@<ip>/tmp/<filename> .

this should be the <filename> from windows location c:\cygwin\tmp\. However I am only getting
cp: cannot stat `scp://<username>@<ip>/tmp/<filename>': No such file or directory.

Still looking.

michaelk 06-24-2016 09:11 PM

It helps if you explain the problem accurately. The quality of the answers is only as good as the information provided.
Is the ssh server configured and running on the Windows PC?

Code:

cp scp://<username>@<ip>/tmp/<filename> .
Is not correct syntax for either the cp or scp commands. The correct scp syntax is:

scp username@ip:source_file destination

http://www.howtogeek.com/howto/41560...-using-cygwin/

gglq000 06-24-2016 11:54 PM

Here, I am sitting on top of my linux machine and I needed to copy from another machine using scp.

If the other machine is linux that is no issue with standard scp command.
cp scp://<username>@<ip>/tmp/<filename> .

If the other machin is Windows, I ran into problem, because syntax is not clear for path.
What you described was you might have assumed that I was sitting in front of Windows machine and trying to copy to/from linux machine. Which is reverse of what I am saying.

Saying that, I got half way done:
Installed cygwin so that Windows machine act like Linux.
However copying is still not working. It turns out sftp/ssh login works but just not scp.
It turns out the Kpym ssh server I am using has no scp server.
Installed Solarwind's free scp/sftp server however, it appears only sftp part is working for Solarwind. It looks Solarwind's tool is buggy.
SolarWind's scp/sftp has configuration where i can specify to start either or both of scp/sftp servers but when fiddling with it, I can only sftp part is working regardless of the setting.
Couple of other scp windows server tools I tried, they are not free so I abandoned 'em.

Turbocapitalist 06-25-2016 05:23 AM

Quote:

Originally Posted by gglq000 (Post 5566019)
If the other machine is linux that is no issue with standard scp command.
Code:

cp scp://<username>@<ip>/tmp/<filename> .

That is not a standard syntax. There is an extraneous "cp", so if it looks like it works then it is actually doing something other than copying from the remote machine. To use "scp" to copy, use it by itself:

Code:

scp://<username>@<ip>/tmp/<filename> .
If you use "cp" first, then all the action will be local and nothing transfered either to or from the remote machine. .

michaelk 06-28-2016 07:20 PM

Been awhile since I've played with cygwin and forgot about no scp. Just use sftp. Very easy to create a script that behaves like scp.

wpeckham 06-28-2016 09:01 PM

Or, as already mentioned, simply use pscp.
There is pscp.exe from the putty intall for windows, and pscp from the putty-tools package for linux, which works in exactly the same way. You do NOT need cygwin for this (though it may be handy for many other things).

cp is never needed to transfer files over an ssh connection, no matter what OS you are talking about. Which really makes me wonder what your commands were REALLY doing!

michaelk 06-28-2016 09:08 PM

The op wants the windows pc to be the server not the client.

wpeckham 06-29-2016 04:55 AM

Quote:

Originally Posted by michaelk (Post 5567687)
The op wants the windows pc to be the server not the client.

I see. That original post is really terribly misleading.
There is a solution form BitVise that would work, and is free for personal use and about $100 if you need a license for business use. Personally, I prefer this one: https://winscp.net/eng/docs/guide_wi...openssh_server

http://sshwindows.sourceforge.net/ should also work. This is a cygwin base solution that does not require compiling in cygwin: http://sshwindows.sourceforge.net/

Nothing is going to be perfect. Everyone (Except Microsoft) knows that Windows sucks at server side stuff, and this is that. That said, any of these solutions should be adequate for file transfer using sftp protocol.

Speaking of which: pscp can be set to use the sftp protocol explicitly using a simple command-line option. Sftp protocol is supported for all ssh server versions that are at all standard and compliant. scp itself as a protocol is not always supported properly, or even well defined. Using pscp, lftp, or another transfer tool that can be used with correct sftp protocol may solve problems you may face using scp alone. (Not really advice, just a comment you may want to keep in mind for future reference.)

sundialsvcs 06-29-2016 10:11 AM

This question is getting very muddled. Let's break it down into its component parts.

(1) The computer that is being connected to must run an SSH daemon.

(2) The computers that are connecting must have SSH-client software appropriate for their operating system. For Windows, that is "Putty."

(3) Ordinarily, they must also be running an "SSH Agent." For Windows, that is "PAgent." (Or is it, "pageant?")

With these three things in place, both secure-copying and secure shell connections can be accomplished.

wpeckham 06-30-2016 05:39 AM

Quote:

Originally Posted by sundialsvcs (Post 5567933)
(3) Ordinarily, they must also be running an "SSH Agent." For Windows, that is "PAgent." (Or is it, "pageant?")

With these three things in place, both secure-copying and secure shell connections can be accomplished.

Not saying you are incorrect, but number three is entirely optional, not required.

For the Linux side OpenSSH will do, is you have installed everything. Putty-tools can be added if you really like the putty style and options, or need the added features.
For the Windows side, putty serves the client part nicely. The server side requires a listener, the tools I suggested would serve. One could google for other options, there are a few free and many paid packages.

wpeckham 07-05-2016 05:57 AM

need to use scp command but with cp command and copy from Windows
 
OP: we have not heard from you in a while. did you resolve your issue?


All times are GMT -5. The time now is 01:45 AM.