Can I transfer files using SSH?

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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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:somepathtoafile.txt <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dbaea8bea99ba9beb6b4afbe">[email protected]</a>:homeusersomepath

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:somepathtoafile.txt <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5a2f293f281a283f37352e3f">[email protected]</a>:homeusersomepathnewname.txt

To download a file from a remote server to your computer:

c:pscp <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="06737563744674636b697263">[email protected]</a>:homeusersomefile.txt c:somepathtoa

or

c:pscp <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="02777167704270676f6d7667">[email protected]</a>:homeusersomefile.txt c:somepathtoanewfile.txt

or

c:pscp <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e095938592a092858d8f9485">[email protected]</a>:homeusersomefile.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

Method 2

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:MEGAps.key" [email protected]:/home/nick/ps.key

remote->local (copy from remote host):

scp -P 1688 [email protected]:/home/nick/ps.key "D:MEGAps.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

Method 3

You might have to use forward slashes (/) to talk with LINUX/UNIX servers

c:pscp c:somepathtoafile.txt <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="99eceafcebd9ebfcf4f6edfc">[email protected]</a>:/home/user/some/path

Method 4

You can use WinSCP for this. It’s much easier than the other tools listed, it provides a simple drag and drop UI.

Method 5

You can just ball a lot of files up with tar:

tar -cz . | ssh <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d3beb693a0b0bbbcbcbf">[email protected]</a> -- '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 <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="53262036211321363e3c2736">[email protected]</a> 'cat >./remotefile'

Method 6

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.

Method 7

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]


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x