How to Upload Files Onto a Linux Server

In that location are multiple methods you tin can use to transfer files between your car and Linux server, some of which we'll discuss in this commodity.

  • using the SCP control in SSH
  • using Netcat
  • using FTP
  • using Python'south Simple HTTP Server

Using SCP (SSH)

SCP is a utility used to motility files and directories securely via SSH. With the SCP command, you tin can transfer files from your computer to your Linux server and vice versa. Equally this utility uses SSH to motion files, you'll need the SSH credential of your server to transfer files.

SSH comes pre-installed on well-nigh Linux servers, but if not, y'all can install and enable it using the following steps.

Open the Ubuntu last and type.

$ sudo apt install -y openssh-server
$ sudo service ssh get-go

Upload files via SCP

Scp command follows this pattern

$ scp [Options] [Source] [Destination]

To transfer a file from your estimator to a linux server, write these commands

$scp /path/of/your/local/file.ext [email protected]:/path/of/ file.ext -i key.pem

In the above command, outset, you lot have to give the path of the file you desire to copy from your reckoner to the Linux server, then the username and IP address of the Linux server, and the path where you want to copy the file on the Linux server fallowing this blueprint ([email protected]: path/of/remote/file.ext).

After running this command, it will require the password of the Linux server user account

After entering the countersign, the file will exist uploaded.

Download files via SCP

To download files from the Linux server to your computer, you lot need to provide SCP with the local path of the file or directory and the path on the Linux Server where yous'd desire your file to be uploaded.

$ scp [e-mail protected]:/path/of/file.ext  /path/to/destination

After running this command, it will require the authentication password of the linux server. Once you lot have entered the password, then the file will be copied safely to your reckoner.

SCP Command-Line Options

You can use dissimilar flags(known as command-line options) in the SCP control.

-p flag is used to change the port. Past default, ssh uses the 22 port, simply with the -p flag, we can change port 22 to something else, like 2222.

$ scp -p 2222 path/of/your/local/file.ext user[email protected]: path/of/file.ext

-r flag is used to copy the folder and all of its content.

$ scp -r /path/of/your/local/folder [email protected]: /path/of/binder

-i flag is used to authenticating the connexion using a cryptographic key pair stored in a file instead of a username and password.

$ scp -i path/of/your/local/file.ext [email protected]: path/of/file.ext

-c flag is used to shrink the data that yous want to transfer.

$ scp -c path/of/your/local/file.ext [email protected]: path/of/file.ext

-q flag is used to suppress the non-error message and progress meter.

$ scp -q /path/of/your/local/file.ext [email protected]: /path/of/file.ext

Transfer Files Using Netcat

Netcat is a Linux utility used for raw tcp/ip communication, transferring files, port scanning, and network troubleshooting, etc. It comes pre-installed in many Linux-based systems, and it is mainly used by Network Administrators.

If not already installed, you can install Netcat by typing the following command

$ sudo apt-get install netcat

To transfer files using Netcat, you have to blazon these commands. Turn the Netcat server on listening mode on whatever port, e.thousand.(port 4747), and type the path of the file you desire to send.

$ nc -50 -p 4747 < path/of/file.ext

On the receiving host, run the following command.

$ nc sending-server.url.com 4747 > path/of/file.ext

Annotation: The server sending file volition use less than sign in the command '<' while the receiving reckoner volition have '>' in the netcat command.

You tin likewise transfer directories. Set up the receiving host to heed on a port, e.m. (4747).

$ nc -50 -p 4747 | tar -zxfv  /path/of/directory

Transport it to the receiving host listing on the port.

$ tar czvf - /path/of/directory | nc receiving-hast.url.com 4747

The directory will exist transferred. To close the connexion, printing CTRL+C

Transfer Files Using FTP

FTP (file transfer protocol) is used to transfer files between computers or clients and servers. It is faster than HTTP and other protocols in terms of file transfer because it is specifically designed for this purpose. It allows you to transfer multiple files and directories, and if in that location is any interruption in the connexion during the transfer, the file will non be lost. Instead, it will resume transferring where it got dropped.

You lot tin can install an FTP server like vsftpd using apt by running this command.

$ sudo apt install -y vsftpd

After the package has been installed, you have to outset the service by typing.

$ sudo systemctl commencement vsftpd
$ sudo systemctl enable vsftpd

Then you can connect to the FTP server by typing the control FTP and the IP accost.

It will inquire you lot the username and countersign of the FTP server. Afterward y'all accept entered the username and password, you will be connected to your FTP server.

You can list out all the contents of the server by executing this command.

Download via FTP

If you want to download whatever file from the FTP server, so y'all can get it by typing the command.

The file will be downloaded. You tin can likewise employ different wildcards to download multiple files in a directory. For example ;

It volition download all the files with the extension ".html" .

You can also set up a local directory for downloaded files from the FTP server by using the lcd command.

ftp> lcd  /home/user/directory-proper name

Upload files via FTP

To upload files on the FTP server, type the following command.

ftp> put  path/of/local/file

The file volition be uploaded to the FTP server. To upload multiple files, blazon commands.

It volition upload all the files with the extension ".html" .

Downloading  files using Python

Python has a module chosen 'http.server', which is used to transfer files, but with it, you can merely download files.

If yous don't have the python installed, then type the following command.

$ sudo apt install -y python3

To turn on the python server, use the control.

$ sudo  python3  -grand  http.server 4747 #[port e.g.(4747)]

At present the python server is listening on port 4747.

Go to your web browser and type the IP address and port no. on which the python server is listening.

http://IP_Address:4747/

A page will open up containing all the files and directory on the python server. Yous can go into any directory and download the files.

Y'all can go into whatsoever directory and download whatever file.

Conclusion

SCP, Netcat, FTP, and Python are ordinarily used methods to transfer files. All of the higher up methods of transferring files and directories are fast, reliable, and used in mod days. In that location are a lot of other techniques too; you can adopt whatever method yous prefer.

About the author

A security enthusiast who loves Final and Open Source. My area of expertise is Python, Linux (Debian), Bash, Penetration testing, and Firewalls. I'grand born and raised in Wazirabad, Pakistan and currently doing Undergraduation from National Academy of Science and Technology (NUST). On Twitter i get by @UsamaAzad14

dobsonalienighted.blogspot.com

Source: https://linuxhint.com/linux-server-file-transfer/

0 Response to "How to Upload Files Onto a Linux Server"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel