Putty upload file from Windows to linux

I'm facing a nightmare at work. A colleague responsible for what I'm going to describe below handed this responsibility to me and has now left the organization. I have no experience doing any of this stuff. Please excuse my lack of knowledge and long question-I'm not sure what info to include/leave out.

Background

We procure some data from a third party, which is sent to a postgres server and then brought into a linux server where some shell scripts do some transformations. The dataset is then combined, after which it is sent to a data analysis tool we use. The process is automated using cron.

However, every year, we need to manually update some metadata csv files on the linux server [these are combined with the 3rd party data using a shell script].

Folder structure:

Below is what the linux server folder structure looks like [accessed using PuTTY]:

  • another_project
  • another_project
  • my_project
  • another_project

~/my_project>

  • shell_scripts
  • procured_files
  • meta_files
  • combined_files

~/meta_files>

  • 2019.csv
  • 2020.csv
  • 2021.csv

What I need to do

What I need to do is add a file called 2022.csv to the meta_files folder. I have the file on my local system. In my colleague's handover document, he simply says to "copy the file to linux using samba share". I've found the samba share location and set it up on my windows explorer. It has an address that looks like this: \\smb.comp.com\prod. There are various sorts of folders in here.

I suspect that I've got to place the 2022.csv file somewhere in the samba share and then run a command on the linux server using PuTTY. However, I've no idea where to put it and what command to run.

I apologize again for such a long question and the excessive description. Any help with how I can get the 2022.csv file onto linux would be greatly appreciated. Please let me know if any other info is required. Many thanks.

Are you looking for a way to quickly transfer files from your Windows computer to your Linux computer and back again? The open source PSCP utility makes it easy to transfer files and folders, and of course it's open source.

Setting your PATH in Windows

Knowing how to set your command path in Windows makes it easier to use a handy utility like PSCP. If you're unfamiliar with that process, read how to set a PATH on Windows.

Using PSCP

PSCP (PuTTY Secure Copy Protocol) is a command-line tool for transferring files and folders from a Windows computer to a Linux computer.

  1. Download pscp.exe from its website.

  2. Move pscp.exe to a folder in your PATH (for example, Desktop\App if you followed the PATH tutorial here on Opensource.com). If you haven't set a PATH variable for yourself, you can alternately move pscp.exe to the folder holding the files you're going to transfer.

  3. Open Powershell on your Windows computer using the search bar in the Windows taskbar (type 'powershell` into the search bar.)

  4. Type pscp –version to confirm that your computer can find the command.

IP address

Before you can make the transfer, you must know the IP address or fully-qualified domain name of the destination computer. Assuming it's a computer on your same network, and that you're not running a DNS server to resolve computer names, you can find the destination IP address using the ip command on the Linux machine:

[linux]$ ip addr show | grep 'inet '
inet 127.0.0.1/8 scope host lo
inet 192.168.1.23/24 brd 10.0.1.255 scope global noprefixroute eth0

In all cases, 127.0.0.1 is a loopback address that the computer uses only to talk to itself, so in this example the correct address is 192.168.1.23. On your system, the IP address is likely to be different. If you're not sure which is which, you can try each one in succession until you get the right one (and then write it down somewhere!)

Alternately, you can look in the settings of your router, which lists all addresses assigned over DHCP.

Firewalls and servers

The pscp command uses the OpenSSH protocol, so your Linux computer must be running the OpenSSH server software, and its firewall must allow SSH traffic.

If you're not sure whether your Linux machine is running SSH, then run this command on the Linux machine:

[linux]$ sudo systemctl enable --now sshd

To ensure your firewall allows SSH traffic, run this command:

[linux]$ sudo firewall-cmd --add-service ssh --permanent

For more information on firewalls on Linux, read Make Linux stronger with firewalls.

Transfer the file

In this example, I have a file called pscp-test.txt that I want to transfer from C:\Users\paul\Documents on my Windows computer to my destination Linux computer home directory /_home_/paul.

Now that you have the pscp command and the destination address, you're ready to transfer the test file pscp-test.txt. Open Powershell and use the dir command to change to the Documents folder, where the sample file is located:

PS> dir %USERPROFILE%\Documents\

Now execute the transfer:
 

PS> pscp pscp-test.txt paul@192.168.1.23:/home/paul
| Password:
End of keyboard-interactive prompts from server
pscp-test.txt | 0 kb | 0.0 kB/s | ETA: 00:00:00 | 100%

Here's the syntax, word for word:

  • pscp: The command used to transfer the file.

  • pscp-test.txt is the name of the file you want to transfer from Windows.

  • is my username on the Linux computer, and the IP address of the Linux computer. You must replace this with your own user and destination information. Notice that pscp requires a destination path on the target computer, and :/home/paul at the end of the IP address specifies that I want the file copied to my home folder.

After you authenticate to the Linux computer, the pscp-test.txt file is transferred to the Linux computer.

[ Related read Share files between Linux and Windows computers ]

Verifying the transferred

On your Linux computer, open a terminal and use the ls command to verify that the file pscp-test.txt appears in your home directory.
 

[linux]$ ls
Documents
Downloads
Music
Pictures
pscp-test.txt

Copying a file off of a Linux system

You aren't limited to just copying files to your Linux system. With pscp, you can also copy a file from Linux onto Windows. The syntax is the same, only in reverse:

PS> pscp paul@192.168.1.23:/home/paul/pscp-test.txt %USERPROFILE%\Documents\pscp-win.txt

Here's the syntax:

  • pscp: The command used to transfer the file.

  • :/home/paul/pscp-test.txt is my username on the Linux computer, the IP address of the Linux computer, and the path to the file I want to copy.

  • %USERPROFILE%\Documents is the location on my Windows computer where I want to save the file. Notice that in copying the file back to my Windows computer, I can give it a new name, such as pscp-win.txt, to differentiate it from the original. You don't have to rename the file, of course, but for this demonstration it's a useful shortcut.

Open your file manager to verify that the pscp-win.txt file was copied to the Windows C:\Users\paul\Documents path from the Linux computer.

Putty upload file from Windows to linux

Image by:

(Paul Laubscher, CC BY-SA 4.0)

Remote copying

With the power of the open source pscp command, you have access to any computer in your house, and servers you have accounts on, and even mobile and edge devices.

Putty upload file from Windows to linux
This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.

How to upload file to Linux server using PuTTY?

How to Upload Files.
Create your custom index. html folder and have it ready to be uploaded to your public_html folder..
Type: >pscp source_filename userid@server_name:/path_destination_filename. ... .
After you are done, open your website by typing in mason.gmu.edu/~username in the browser to see your files..

How to copy file from Windows to Unix using PuTTY?

2 Answers.
Download PSCP.EXE from Putty download page..
Open command prompt and type set PATH=<path to the pscp.exe file>.
In command prompt point to the location of the pscp.exe using cd command..
Type pscp..
use the following command to copy file form remote server to the local system. pscp [options] [user@]host:source target..

Can Windows data transfer to Linux?

File Transfer Protocol (FTP) is another great way to copy your data from Windows to Linux. Many may find this method more manageable since you do not need to type any commands. Check your Linux server and ensure it is up and running for this approach. Also, you'll need an app such as FileZilla to transfer with FTP.

How to copy file from Windows to Linux using SCP?

Select the File Protocol from the drop-down list as SCP first. Add the IP address of Ubuntu within the “Hostname” field. Add user name and password to connect and press Login. After a successful connection, drag the files from the left area to the right side of WinSCP to transfer.