LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 06-24-2016, 02:20 PM   #1
gglq000
Member
 
Registered: Mar 2012
Posts: 65

Rep: Reputation: Disabled
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>??
 
Old 06-24-2016, 05:14 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
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
 
Old 06-24-2016, 05:22 PM   #3
gglq000
Member
 
Registered: Mar 2012
Posts: 65

Original Poster
Rep: Reputation: Disabled
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?
 
Old 06-24-2016, 05:37 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
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

Last edited by michaelk; 06-24-2016 at 05:48 PM.
 
Old 06-24-2016, 07:56 PM   #5
gglq000
Member
 
Registered: Mar 2012
Posts: 65

Original Poster
Rep: Reputation: Disabled
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.
 
Old 06-24-2016, 09:11 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
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/
 
Old 06-24-2016, 11:54 PM   #7
gglq000
Member
 
Registered: Mar 2012
Posts: 65

Original Poster
Rep: Reputation: Disabled
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.
 
Old 06-25-2016, 05:23 AM   #8
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,295
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
Quote:
Originally Posted by gglq000 View Post
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. .
 
Old 06-28-2016, 07:20 PM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
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.
 
Old 06-28-2016, 09:01 PM   #10
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,598

Rep: Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691
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!
 
Old 06-28-2016, 09:08 PM   #11
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,681

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
The op wants the windows pc to be the server not the client.
 
Old 06-29-2016, 04:55 AM   #12
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,598

Rep: Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691
Quote:
Originally Posted by michaelk View Post
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.)

Last edited by wpeckham; 06-29-2016 at 04:56 AM.
 
Old 06-29-2016, 10:11 AM   #13
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,649
Blog Entries: 4

Rep: Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935Reputation: 3935
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.
 
Old 06-30-2016, 05:39 AM   #14
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,598

Rep: Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691
Quote:
Originally Posted by sundialsvcs View Post
(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.
 
Old 07-05-2016, 05:57 AM   #15
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,598

Rep: Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691Reputation: 2691
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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: SCP (Secure Copy) Command Tutorials with Practical Examples LXer Syndicated Linux News 0 10-04-2013 01:42 AM
how to copy drive using dd and tee command parallely? source code of dd command mdfakkeer Linux - Software 1 02-10-2010 01:31 PM
Translating windows pscp command to linux scp command help robward Linux - General 2 01-17-2008 06:02 AM
How to copy files via command line from Redhat to windows chris28 Linux - Networking 5 01-23-2006 11:55 PM
SCP Copy from Linux to Windows? mhague Linux - Newbie 8 11-03-2004 01:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 04:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration