I am using PuTTY on Windows 7 to SSH to my school computer lab. Can I transfer files from my Windows machine to my user on the school machines using SSH?
-
I'm voting to close this question as off-topic because it's about Windows, not Unix. – dr_ Jul 06 '18 at 10:12
-
2@dr01 true but it's got a lot of upvotes so it's probably worth leaving for posterity, and moving on. – roaima Jul 06 '18 at 13:33
7 Answers
Use the PSCP tool from the putty download page:
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
PSCP is the putty version of scp which is a cp (copy) over ssh command.
PSCP needs to be installed on your windows computer (just downloaded, really, there is no install process. In the Packaged Files section, pscp.exe is already included). Nothing needs to be installed on the school's servers. PSCP and scp both use ssh to connect.
To answer the usage question from the comments:
To upload from your computer to a remote server:
c:\pscp c:\some\path\to\a\file.txt user@remote:\home\user\some\path
This will upload the file file.txt to the specified directory on the server. If the final part of the destination path is NOT a directory, it will be the new file name. You could also do this to upload the file with a different name:
c:\pscp c:\some\path\to\a\file.txt user@remote:\home\user\some\path\newname.txt
To download a file from a remote server to your computer:
c:\pscp user@remote:\home\user\some\file.txt c:\some\path\to\a\
or
c:\pscp user@remote:\home\user\some\file.txt c:\some\path\to\a\newfile.txt
or
c:\pscp user@remote:\home\user\some\file.txt .
With a lone dot at the end there. This will download the specified file to the current directory.
Since the comment is too far down, I should also point out here that WinSCP exists providing a GUI for all this, if that's of interest: http://winscp.net/eng/download.php
- 103
- 4
- 1,922
- 16
- 8
-
I can't install anything on the university computers of course. Do I need to? – Alex Mohr Sep 27 '13 at 22:39
-
Is the windows 7 machine yours or your schools? I read the question to suggest that your are using putty on *your* computer to connect to the school's. If that is the case, then you do not need to install anything on the school's computer, but you will need to on yours. – SuperMagic Sep 27 '13 at 22:40
-
I'm using my windows 7 machine. thanks! I found the wget command and I used dropbox to transfer the file, but I'll keep this in mind for sure – Alex Mohr Sep 27 '13 at 22:42
-
One more thing: scp works both ways. You can upload as well as download with it. – SuperMagic Sep 27 '13 at 22:44
-
I'm having a bit of trouble with the syntax of the command. Is it: `pscp source "path_to_local_file" user@host:path_to_new_location` ? I got it to work with leaving the path on the remote machine blank, it just put it in my root directory. – Alex Mohr Sep 27 '13 at 22:49
-
updated the answer to show usage examples. The standard unix scp works the same way. – SuperMagic Sep 27 '13 at 23:02
-
I guess I should also point out that there is a WinSCP program which provides a graphical interface to all this: http://winscp.net/eng/download.php – SuperMagic Sep 27 '13 at 23:07
-
you can use Windows PowerShell (actually, it's OpenSSH command, it can be used on any UNIX OS too):
scp -P <non-default target ssh port> "<source file>" <username>@<hostname/address>:<destination path>
-P flag can be omitted if ssh opened on default port (22)
switch places of local and remote paths to copy file from remote host
e.g.:
- copying file "ps.key" via ssh
- local OS is Windows 10
- remote address is 192.168.88.242, ssh (daemon) works on port 1688
- remote username is "nick"
command:
local(win)->remote(unix):
scp -P 1688 "D:\MEGA\ps.key" [email protected]:/home/nick/ps.key
remote->local (copy from remote host):
scp -P 1688 [email protected]:/home/nick/ps.key "D:\MEGA\ps.key"
After this, you should confirm target key fingerprint (if you haven't connected to this host via PowerShell before) and authenticate yourself on remote host (enter user password or ssh-key password if not using ssh-agent).
should work on win10 w/o any installations, since OpenSSH is built-in there
- 111
- 1
- 4
-
That doesn't look like a Powershell command. Are you sure it isn't `scp` from the PuTTY suite? – roaima Jul 06 '18 at 13:34
-
@roaima OpenSSH has been available as an optional but built-in part of Windows 10 since the Fall Creator's update (Late 2017) and has been installed by default since the April 2018 update. The `scp` command is included. – Bob Sammers Aug 28 '18 at 14:17
-
1@BobSammers oh so it is. (Mine's masked by a Cygwin install.) It's not Powershell, though, in any unified sense. Command-line certainly, but not Powershell. – roaima Aug 28 '18 at 14:26
-
Actually this is the easiest solution, I just tried with PShell on my Windows and it opens a SSH on RHEL, ask for Password, copy the file and close. And it works! – Raffaeu Mar 11 '19 at 11:40
-
You might have to use forward slashes (/) to talk with LINUX/UNIX servers
c:\pscp c:\some\path\to\a\file.txt user@remote:/home/user/some/path
- 311
- 2
- 5
You can use WinSCP for this. It's much easier than the other tools listed, it provides a simple drag and drop UI.
- 91,316
- 38
- 238
- 232
- 81
- 1
- 1
-
Not clear what relation this has to the question asked. Unless it's just the name of a client program, and the rest is junk. – Tom Hunt Sep 08 '15 at 22:51
-
1Maybe the question changed over time but this is the answer I was looking for: this is a program with a gui that can browse and transfer files over ssh. It even imports settings from Putty. Very handy imho, just didn't remember its name, thx – Emile Vrijdags Feb 28 '18 at 13:31
-
Thanks it's really handy `program with a gui that can browse and transfer files over ssh` is the best chose for someone like me :) – Yousef Altaf Jun 11 '20 at 13:04
You can just ball a lot of files up with tar:
tar -cz . | ssh me@school -- 'tar -C/path/to/target/dir -xz'
...which would recursively compress and stream all files in the current directory on the local machine to the target path while simultaneously uncompressing and expanding the stream on the remote machine.
You can do similar things for anything that writes to stdout. cat is an obvious choice:
cat ./localfile | ssh user@remote 'cat >./remotefile'
- 57,448
- 9
- 113
- 229
-
1
-
@Joe - the same way? Maybe `<./localfile putty user@remote 'cat >./remotefile'` - I forgot all of the putty switches. But it's pretty close – mikeserv Jul 24 '15 at 14:38
-
1The Windows/PuTTY version would be: type localfile | plink user@remote "cat > remotefile" – Adam Haun Jan 12 '18 at 21:09
Since you are already familiar with putty. I suggest you take a look at https://mobaxterm.mobatek.net/. MobaXterm has everything you need to remote work on Linux from windows computer, ssh, sftp, scp, Xwindows are all included. It is much better than putty, in my opinion.
- 11
- 2
-
Is it also free (of charge) for none-personal use; eg to SSH to a school computer lab (as in the question)? – Pierre.Vriens Oct 24 '18 at 19:24
-
yes. MobaXterm is free even for commercial use unless you need to save 10+ sessions. I am a software developer, and the free version works perfectly for my job. For school work, just go ahead. – Cen R. Oct 25 '18 at 20:13
Use Beyond Compare tool if your not a command line guru. Beyond Compare is a folder comparison tool and has a nice user interface and allows you to use SFTP and SSH private key file for different environments your trying to log into. Here is the link to the tool [https://www.scootersoftware.com/][1]
- 1