Upload Files to Remote Server With Unbuntu Desktop
There are multiple methods y'all can use to transfer files between your machine and Linux server, some of which we'll hash out in this article.
- using the SCP command in SSH
- using Netcat
- using FTP
- using Python'south Simple HTTP Server
Using SCP (SSH)
SCP is a utility used to move files and directories securely via SSH. With the SCP command, you lot can transfer files from your estimator to your Linux server and vice versa. As this utility uses SSH to move files, you'll need the SSH credential of your server to transfer files.
SSH comes pre-installed on virtually Linux servers, only if not, you can install and enable it using the following steps.
Open the Ubuntu terminal and type.
$ sudo apt install -y openssh-server
$ sudo service ssh start
Upload files via SCP
Scp command follows this pattern
$ scp [Options] [Source] [Destination]
To transfer a file from your computer to a linux server, write these commands
$scp /path/of/your/local/file.ext [email protected]:/path/of/ file.ext -i central.pem
In the above control, get-go, you have to give the path of the file yous want to copy from your computer to the Linux server, and so 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).
Subsequently running this command, it volition require the password of the Linux server user account
Afterward entering the countersign, the file volition exist uploaded.
Download files via SCP
To download files from the Linux server to your estimator, y'all need to provide SCP with the local path of the file or directory and the path on the Linux Server where you'd want your file to be uploaded.
$ scp [email protected]:/path/of/file.ext /path/to/destination
Subsequently running this command, it volition require the authentication countersign of the linux server. Once y'all take entered the countersign, then the file will be copied safely to your figurer.
SCP Command-Line Options
You can use different flags(known as command-line options) in the SCP command.
-p flag is used to change the port. By default, ssh uses the 22 port, but with the -p flag, nosotros can alter port 22 to something else, like 2222.
$ scp -p 2222 path/of/your/local/file.ext [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/binder [email protected]: /path/of/folder
-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 [e-mail protected]: path/of/file.ext
-c flag is used to compress the data that you lot 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 [electronic mail 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 non already installed, you tin install Netcat by typing the post-obit command
$ sudo apt-get install netcat
To transfer files using Netcat, you have to blazon these commands. Plow the Netcat server on listening fashion on whatsoever port, e.g.(port 4747), and type the path of the file you want to send.
$ nc -l -p 4747 < path/of/file.ext
On the receiving host, run the following command.
$ nc sending-server.url.com 4747 > path/of/file.ext
Note: The server sending file will employ less than sign in the command '<' while the receiving reckoner will take '>' in the netcat command.
You lot can also transfer directories. Set the receiving host to heed on a port, e.g. (4747).
$ nc -l -p 4747 | tar -zxfv /path/of/directory
Send it to the receiving host listing on the port.
$ tar czvf - /path/of/directory | nc receiving-hast.url.com 4747
The directory volition be transferred. To shut the connection, press CTRL+C
Transfer Files Using FTP
FTP (file transfer protocol) is used to transfer files between computers or clients and servers. Information technology is faster than HTTP and other protocols in terms of file transfer because it is specifically designed for this purpose. It allows you lot to transfer multiple files and directories, and if there is any break in the connection during the transfer, the file will not be lost. Instead, it will resume transferring where it got dropped.
Y'all can install an FTP server like vsftpd using apt past running this command.
$ sudo apt install -y vsftpd
After the package has been installed, you have to starting time the service past typing.
$ sudo systemctl get-go vsftpd
$ sudo systemctl enable vsftpd
Then you tin connect to the FTP server by typing the command FTP and the IP address.
It will ask you the username and countersign of the FTP server. After you accept entered the username and password, you will be continued to your FTP server.
You can list out all the contents of the server by executing this command.
Download via FTP
If y'all desire to download any file from the FTP server, then you tin can get it by typing the command.
The file volition be downloaded. Yous tin too use different wildcards to download multiple files in a directory. For case ;
It will 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 noun
Upload files via FTP
To upload files on the FTP server, type the post-obit control.
ftp> put path/of/local/file
The file will be uploaded to the FTP server. To upload multiple files, type commands.
Information technology volition upload all the files with the extension ".html" .
Downloading files using Python
Python has a module called 'http.server', which is used to transfer files, but with it, y'all can only download files.
If you 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 -m http.server 4747 #[port e.g.(4747)]
Now the python server is listening on port 4747.
Become to your web browser and type the IP address and port no. on which the python server is listening.
http://IP_Address:4747/
A folio will open up containing all the files and directory on the python server. You lot tin can go into whatever directory and download the files.
Y'all can become into any directory and download any file.
Conclusion
SCP, Netcat, FTP, and Python are commonly used methods to transfer files. All of the above methods of transferring files and directories are fast, reliable, and used in modern days. There are a lot of other techniques also; you can adopt any method y'all prefer.
Source: https://linuxhint.com/linux-server-file-transfer/
Post a Comment for "Upload Files to Remote Server With Unbuntu Desktop"