Copy Files Between Windows and Linux Using Command Line
It is not always that you will need to copy a file from Windows to Linux or vice versa. But at times when you are automating things or trying to achieve some copy functionality using a script, it is good to have a utility to do that. Here is where pscp comes into play. Using pscp you can copy the file to/from windows and Linux. In this guide, I will go through the steps of doing the same.
Copy File from Windows To Linux
1. Download pscp.exe from here
2. copy the pscp.exe executable to the system32 directory of your windows machine. This folder normally exists in C:\Windows\System32 path.
3. Open PowerShell and use the following command to verify if pscp is accessible from the path.
4. Use the following format to copy the file to the Linux box.
-pw for the password.
replace password with the Linux user password.
C:\Users\Admin\Desktop\test.txt represents the path of the file that has to be copied to the Linux system.
192.168.33.10 is the IP of the Linux server.
/home/vagrant is the user-accessible path in the Linux system to copy the file.
If you are using private keys for authentications, you can use -i flag instead of -pw followed by the path to the .ppk file. If your key file is in pem format, you can use the puttygen command to convert it to ppk.
Info: Learn Linux & Windows administration from Pluralsight with its 10 days free account
For key-based authentication, the command looks like below.
Copy File From Linux To Windows
You can use pscp to copy files from Linux to windows. use the following command format for the same.
The above command will copy the file in Linux from the specified path to the Windows desktop.
Ssh copy from windows to linux
Great post, very clear to follow. But when i get to «First Remote Login to your Linux computer with Password Authentication» step. I got the following message:
DIsconnected: No supported authentication methods available(server sent: publickey)
How can i fix it?
thanks in advance for your time
Sign In· View Thread
My vote of 5
Dmitry Leonov
8-Mar-19 6:26
Really, really useful! You saved me a lot of time! Thanks a lot!
Sign In· View Thread
Re: Not asking not telling /Public Key Authentication
Member 14149118
13-Feb-19 1:34
This was an absolutely great article to learn how to use ssh/sshd and putty. I just wanted to point out that when we were supposed to try using the public key authentication login for the first time it might help if you describe that there is a default + next to the SSH option on the left side nav menu that must be expanded to find the auth features. My vision not being the greatest I was doing great all the way through the tutorial until I couldn’t figure out where to «browse» for my privatekey. I was pulling my hair out for 15 minutes trying to figure out where that option is..and I believe once you have found it (and filled it in) that that is what «tells» putty to use key authentication vice PAM/UserPassword! A remark on that particular tree navigation point might be a nice addition! Thank you for helping me get up and running! Great job!
I see no has posted to this in a while. I just wanted to say this article worked perfectly for me. Thank You!
Sign In· View Thread
append YourPublicKey to EXISTING file
Member 12012287
25-Sep-15 12:31
In the nice article you say «This command will append YourPublicKey to the file authorized_keys. If the file does not exist, it will be created (ours doesn’t exist yet. If yours DOES, don’t do this this way).»
. but what if the authorized_keys file DOES EXIST ? . you don’t say how to add to it .
Except for this it is a very helpful and well done article..Thank you .
Curt
Sign In· View Thread
My vote of 5
wyckster
25-Apr-15 18:07
Very detailed, explanatory and helpful.
Sign In· View Thread
Re: My vote of 5
Member 12945051
11-Jan-17 2:20
agree. Every instruction was clear and helpful for a beginner like me
Sign In· View Thread
Post about connecting to server over the internet (not LAN) via SSH
Member 11496931
3-Mar-15 20:54
This was an amazing article! to the point and precise. You mentioned about posting another about connecting a server over the global internet? i cant seem to find it. could you comment the link? Thank you for this and our other amazing tutorials!!
Sign In· View Thread
Not asking/telling — Public Key Authentication
Member 10507507
6-Jan-14 17:40
Hi
I stumbled across this site as I was trying to find a way to connect to my FreeNAS box from my windows 7 PC. I am trying to shutdown that PC using a batch file after a process is run from my Windows PC.
The process that you have shown in great detail is absolutely marvellous! I was able to connect to my FreeNAS Unix/Linux box using SSH and do the file manipulations etc.
One question though is that whilst I have copied the public key in the authorized_key file on the Unix PC and everything seems to be ok but when I try to connect using the SSH connection, it still asks for my password (that’s possibly because I haven’t yet stopped the access using password authentication) but it doesn’t tell me that its trying to do a ‘public key authentication’ — so I don’t know if its connecting me through password or public key — is there any other way to tell.
Initially, I got the ‘Server refused our key’ but after repeating the process a few times, I don’t get that error but I am still not sure how am I connecting ot my Unix PC?
Can you please advise?
Deepak
Sign In· View Thread
Re: Not asking/telling — Public Key Authentication
John Atten
6-Jan-14 18:15
It’s been a while since I have done this, but I believe if Password Authentication is enabled, then that is what you will get logged in with. I suspect that if you want to use public key encryption, you need to disable the password auth.
I could be wrong, but try doing that, and let us know what happens.
Thanks for reading, and do please let me know what you find out. I will see if I can look back at this after work tomorrow if you still haven’t got it figured out.
Cheers!
Sign In· View Thread
Re: Not asking/telling — Public Key Authentication
Member 10507507
6-Jan-14 19:05
This is what is get when I try to connect with SSH authentication (because I can’t attach the screen dump I will try and simulate what I see on the screen) :-
Using username «anyone». anyone@192.168.1.3’s password :
I then enter the password and I am logged in
But this is not logging through Public Key Authentication, is it?
Further, when I try to shutdown or reboot that PC, it says permission denied.
Where do I need to change the permissions so that I can do this or how do I log on as root (I assume that root can do that — but there is not password for root at this point)
Deepak
Sign In· View Thread
Re: Not asking/telling — Public Key Authentication
Member 10507507
8-Jan-14 23:28
Don’t worry about not being able to shutdown/reboot — can do that now! Had to change the sudoers file on the server. That aspect is ok!
However,I am still not connecting via ssh using public key authentication — I am doing so using password authentication. Is this what is stopping me from connecting via Plink?
How do I disable password authentication? Secondly, if I do that, how would I be log in if the public key authentication doesn’t work? My concern is that I have to eventually connect to this server using a batch file. For that purpose, I have downloaded Plink and made the changes as I have understood from some article available on the net but I am not able to connect as yet through Plink even though I am able to connect via PuTTY.
Deepak
Sign In· View Thread
Re: Not asking/telling — Public Key Authentication
John Atten
9-Jan-14 0:48
Hmmm. You’re right.
I pretty much walk through how to disable password auth. But you are correct, you really can’t disable that until you know the public key thing is working.
When I was having difficulty with this, it was usually related to properly adding the key to the authorized_keys file, and/or properly setting the permissions.
If you can, download (or copy the text from) your sshd_config file, and your authorized_keys file. Once done, immediately delete the current key, create a new key pair and repeat the key process (because I want you to send me the current key file, and I am just some stranger from the internet!). Really, don’t do this part unless you can immediately change the key out.
Then email both to me at xivsolutions at gmail dot com.
Then I can take a look and see if there is anything you might be doing wrong.
Also, take a series of screen shots showing your putty configuration and send those two.
In both, obviously, redact any confidential info.
I will 100% understand if you’re not comfortable with this, but it’s the only way I can think of to trouble-shoot the situation.
Sign In· View Thread
Great Post — stuck on «First Remote Login to your Linux computer with Password Authentication»
Pointyhead
29-Dec-13 5:58
I’m learning a lot from this post, however I can’t seem to get past the step «First Remote Login to your Linux computer with Password Authentication». I get an error «Disconnected: No supported authentication methods available (server sent: publickey)». I don’t mind doing a little troubleshooting, but I could use some guidance. Is this a problem I have to address on the server machine?
Thanks, Stephen
Sign In· View Thread
Re: Great Post — stuck on «First Remote Login to your Linux computer with Password Authentication»
Pointyhead
29-Dec-13 8:50
Alright — I managed a solution. I simply uninstalled and reinstalled my openssh on the server machine. This did the trick.
S
Sign In· View Thread
Re: Great Post — stuck on «First Remote Login to your Linux computer with Password Authentication»
John Atten
29-Dec-13 11:55
Good deal man, glad you figured it out!
Sorry I wasn’t able to get back to you, I’m traveling at the moment.
Thanks for reading, and for updating with your solution!
Sign In· View Thread
Great post
danny_ncms
18-Oct-13 11:31
Great post
Sign In· View Thread
With having a Public Access Key, how do I transfer files using PSCP to or from my windows box?
Member 10182217
31-Jul-13 14:58
Ok so I’ve followed this guide which broke down everything very neatly, and precisely in easy to follow steps. I’m using a linux box as a home media server for me and my parents, and want to consolidate all the media onto it and have it accessible by the whole family. This includes family pictures and work documents. I’ve got PuTTY and putty-tools installed on windows and linux, respectively. When I type
Sign In· View Thread
Re: With having a Public Access Key, how do I transfer files using PSCP to or from my windows box?
John Atten
31-Jul-13 18:10
My understanding is that between two Linux boxes, one can use the scp command. There is a brief discussion HERE
Since you are using Putty, with a Windows box and a ‘nix box, you will want to check out the PuTTY User Manual (installed with PuTTY in the PuTTY application directory on your Windows Machine). Check out «Chapter 5, Using PSCP to transfer files securely.» It appears there is some configuration required in order to use pscp this way.
From the PuTTY User Manual:
I have not done this myself yet. However, it basically bridges the scp command between Windows and Linux.
Hope that helps. I may just have to do a post on this, after I mes with it this weekend!
Please do let me know how it goes for you . . .
-J
Sign In· View Thread
My vote of 5
Member 10182217
31-Jul-13 14:21
Very simple, very precise, simple but well and to the point.
Sign In· View Thread
ssh_config_backup
yjaber
27-May-13 19:12
I enjoyed a lot reading and practicing this thoroughly detailed blog. Just one comment that the comand «$ sudo /etc/ssh/sshd_config
/ssh_config_backup» is missing the action «cp» to actually copy the configuration file. It should be «$ sudo cp /etc/ssh/sshd_config
Thank you for such an appreciated affort. I will go on and read the next too blogs.
Sign In· View Thread
Re: ssh_config_backup
John Atten
28-May-13 1:27
Ha! Nice catch. Ooops. I will update asap!
Sign In· View Thread
My vote of 5
R. Hoffmann
27-Nov-12 21:36
Wow, you went to great lengths to create a clear, detailed and very helpful guide — thanks very much!
Sign In· View Thread
Re: My vote of 5
John Atten
28-Nov-12 2:21
Thanks for reading! Yes, it was a bit of an undertaking to write out clearly what is a not-too-complicated process. Mainly due to the number of detailed steps involved. Also, I am new to Linux and SSH, so I tried to address the pain points I myself ran into trying to get the job done (online, I found I had to perform multiple searches for different bits of info to get the whole picture in a manner which I could understand).
My next step will be an article explaining how to use the SSH tunnel to remote in to the linux desktop via VNC.
Sign In· View Thread
Last Visit: 31-Dec-99 18:00 Last Update: 19-Apr-21 4:55
Refresh
1
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.