LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-19-2019, 06:56 PM   #1
Chrislw324
Member
 
Registered: Oct 2018
Posts: 40

Rep: Reputation: Disabled
Copying files with ssh from linux to windows


I'm using openssh server on my linux laptop and openssh client on my windows desktop. I'm on my windows desktop using ssh to get into my laptop.
A google search tells me I should be able to copy file from my laptop to my desktop with:

scp -r ~/Documents/Python Chris@192.168.0.10: D:\LaptopBackup

ssh: Could not resolve hostname d: name or service not known
lost connection

Why is this not working?
 
Old 05-19-2019, 07:26 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
I use sftp to copy from the server to the client. I also use WinSCP rather than the command line, but I think you’d connect with sftp (which uses ssh) then do an meet to pull multiple files down.

That said, the error would indicate a syntax issue with your command to me...I’d think the connection info should be first...check the man page.

Last edited by scasey; 05-19-2019 at 07:28 PM.
 
Old 05-19-2019, 07:37 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,703

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Code:
scp -r ~/Documents/Python Chris@192.168.0.10: D:\LaptopBackup
You syntax does not appear to be correct. I don't use widows scp client and therefore do not know how its syntax differs from the linux version but try:

Code:
scp -r Chris@192.168.0.10:Documents/Python/* D:\LaptopBackup
 
Old 05-19-2019, 08:16 PM   #4
Chrislw324
Member
 
Registered: Oct 2018
Posts: 40

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
try:

Code:
scp -r Chris@192.168.0.10:Documents/Python/* D:\LaptopBackup
I tried that, but it didn't work either.

Just to further clarify
I'm on my windows desktop ssh'ing into my linux laptop, and while I'm in there, I'm trying to scp to transfer files
back to my windows desktop.
 
Old 05-19-2019, 08:29 PM   #5
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by Chrislw324 View Post
I tried that, but it didn't work either.

Just to further clarify
I'm on my windows desktop ssh'ing into my linux laptop, and while I'm in there, I'm trying to scp to transfer files
back to my windows desktop.
We don’t know how to help when you say “didn’t work”. What error did you get?
I’m gonna repeat this: Get and use WinSCP to sftp to/from Windows... it’s free, it runs over the PuTTY engine...click and drag or double click from it’s UI.

(It’s why I can’t answer with how to use scp)
 
Old 05-19-2019, 08:39 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,703

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Sorry I over looked that in your first post and misread the title. To transfer files back you need a sftp server running on the Windows desktop computer. Did you install a server on the Windows desktop?

As suggested use a GUI file transfer utility like filezilla or WinSCP do download your files from the linux laptop.

Last edited by michaelk; 05-19-2019 at 08:50 PM.
 
Old 05-19-2019, 09:51 PM   #7
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by Chrislw324 View Post
I'm using openssh server on my linux laptop and openssh client on my windows desktop. I'm on my windows desktop using ssh to get into my laptop.
A google search tells me I should be able to copy file from my laptop to my desktop with:

scp -r ~/Documents/Python Chris@192.168.0.10: D:\LaptopBackup
This command attempts to copy local directory ~/Documents/Python and Chris’ home directory on host 192.168.0.10 to the directory \LaptopBackup on a remote system named D. Not your intention, I guess.

Like michaelk says, perhaps you want
Code:
scp -r Chris@192.168.0.10:Documents/Python D:\LaptopBackup
but you have to tell the scp client that the colon after the D is part of a local name and doesn’t separate the remote host name from the remote directory. I am sure there is an option for this, but I will leave it up to you to read the scp manual.

Last edited by berndbausch; 05-19-2019 at 09:55 PM.
 
Old 05-19-2019, 10:02 PM   #8
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,264
Blog Entries: 24

Rep: Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195Reputation: 4195
Disclaimer: I do not use any M$ OS, nor scp...

But, your actual command syntax still looks suspect to me if I correctly understand the direction.

So, based on your original post, and this...

Quote:
Originally Posted by Chrislw324 View Post
I tried that, but it didn't work either.

Just to further clarify
I'm on my windows desktop ssh'ing into my linux laptop, and while I'm in there, I'm trying to scp to transfer files
back to my windows desktop.
The scp command you show is being issued ON your Linux machine while logged in via SSH from elsewhere - meaning in a shell on the Linux machine:

Code:
scp -r ~/Documents/Python Chris@192.168.0.10: D:\LaptopBackup
So you want to copy file(s) from ~/Documents/Python to the other machine at Chris@192.168.0.10, and put the files into D:\LaptopBackup on that machine.

If so, then from here I find the syntax should be:

Code:
scp {{path/to/local_file}} {{remote_host}}:{{path/to/remote_file}}
I think the space between host and remote file location is killing it. Try this...

Code:
scp -r ~/Documents/Python Chris@192.168.0.10:D:\LaptopBackup
And that assumes that the remote host spec is valid and that it is listening (i.e. server running).

Last edited by astrogeek; 05-19-2019 at 10:09 PM.
 
Old 05-19-2019, 10:03 PM   #9
Soapm
Member
 
Registered: Dec 2012
Posts: 182

Rep: Reputation: Disabled
Not sure if this helps but what I do is mount my windows drive in Debian then I can move files like their on the same machine.
 
Old 05-19-2019, 10:06 PM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,703

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
I even messed up the command syntax in my previous post. Its always source first then destination. The OP wants to transfer files from the linux laptop to the Windows desktop.

astrogeek posted the correct syntax but as far as I know I don't think you can use a scp client on a Windows sftp server...

Last edited by michaelk; 05-19-2019 at 10:07 PM.
 
Old 05-20-2019, 06:38 AM   #11
dc.901
Senior Member
 
Registered: Aug 2018
Location: Atlanta, GA - USA
Distribution: CentOS/RHEL, openSuSE/SLES, Ubuntu
Posts: 1,005

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Quote:
Originally Posted by Chrislw324 View Post
I'm using openssh server on my linux laptop and openssh client on my windows desktop. I'm on my windows desktop using ssh to get into my laptop.
A google search tells me I should be able to copy file from my laptop to my desktop with:

scp -r ~/Documents/Python Chris@192.168.0.10: D:\LaptopBackup

ssh: Could not resolve hostname d: name or service not known
lost connection

Why is this not working?
Server serves the clients, but here you want to the client to serve, which will NOT work. Either your Google search string was wrong or you understood incorrectly.
You CAN connect from your Windows desktop (which is the client) to your Linux laptop (your server).
To do that, download Putty Tools (pscp is the file) to your Windows desktop. Then:
Code:
pscp -r <linuxuser>@<linux_laptop_IP>:~/Documents/Python D:\LaptopBackup
In above command, you are using pscp to connect to you linux laptop as "linuxuser" to copy from "linuxuser"'s /Documents/Python directory to D:\LaptopBackup on your desktop. The "-r" is for recursive copy...

Hope this helps?
 
Old 05-20-2019, 06:02 PM   #12
Chrislw324
Member
 
Registered: Oct 2018
Posts: 40

Original Poster
Rep: Reputation: Disabled
Thanks for all the replies.

No, I don't have an sftp server running on my desktop.
I'll give these suggestions a try when I have to to.
 
Old 05-21-2019, 01:18 AM   #13
iorih0304
LQ Newbie
 
Registered: Jul 2017
Posts: 26

Rep: Reputation: Disabled
If you mean 192.168.0.10 is Linux'ip
You may try this:
Quote:
pwd
scp -r Chris@192.168.0.10:/home/user/test_folder .
And you can find this file on Windows'path: C:\Users\User\Documents\MobaXterm\home\test_folder (for example)
the path is up to where the software sets
 
Old 05-21-2019, 01:33 PM   #14
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
Quote:
Originally Posted by Chrislw324 View Post
I tried that, but it didn't work either.

Just to further clarify
I'm on my windows desktop ssh'ing into my linux laptop, and while I'm in there, I'm trying to scp to transfer files
back to my windows desktop.
This won't work. Especially the last part. Running scp on the linux laptop would require your windows pc to be an ssh server... which it is not.

As was pointed out multiple times, use an sftp/scp client on windows. Filezilla or winscp come to mind. You can not solve this problem with putty alone unless you install an ssh server on your windows machine. You don't want to do this.
SSH on windows is clumsy at best. Get over it and install the tools (i.e. filezilla or winscp) to workaround said shortcomings.
 
  


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
Copying home folder from command line without copying hidden directories and files rm_-rf_windows Linux - General 2 04-12-2016 08:24 AM
drag-drop copying and cp command both hang at last few KB when copying to flash drive slacker_ Linux - Newbie 1 09-05-2013 07:17 AM
[SOLVED] Copying the files inside a folder, without copying the folder (hopefully easy) tibberous Linux - Software 3 12-23-2010 01:50 AM
ssh - copying files wendea Linux - Newbie 12 05-25-2007 02:56 PM
Copying files to local computer whilst in ssh tunnel Maverick1182 Linux - Newbie 4 10-07-2006 01:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:28 PM.

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