How To Upload Files To A Fedora Server
There are multiple methods yous can apply to transfer files between your machine and Linux server, some of which we'll discuss 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 control, you lot tin transfer files from your figurer to your Linux server and vice versa. Every bit this utility uses SSH to move files, you'll demand the SSH credential of your server to transfer files.
SSH comes pre-installed on most Linux servers, but if not, you tin can install and enable it using the following steps.
Open the Ubuntu terminal and blazon.
$ sudo apt install -y openssh-server
$ sudo service ssh first
Upload files via SCP
Scp command follows this blueprint
$ 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 key.pem
In the above command, first, you have to requite the path of the file you want to copy from your computer to the Linux server, so the username and IP address of the Linux server, and the path where you want to re-create the file on the Linux server fallowing this pattern ([email protected]: path/of/remote/file.ext).
After running this command, it will crave the password of the Linux server user account
Later on entering the password, the file volition exist uploaded.
Download files via SCP
To download files from the Linux server to your computer, you need to provide SCP with the local path of the file or directory and the path on the Linux Server where y'all'd want your file to be uploaded.
$ scp [email protected]:/path/of/file.ext /path/to/destination
After running this control, it will require the hallmark password of the linux server. One time you lot have entered the countersign, so the file will be copied safely to your computer.
SCP Command-Line Options
You can utilise different flags(known every bit control-line options) in the SCP control.
-p flag is used to change the port. By default, ssh uses the 22 port, but with the -p flag, nosotros can change 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/folder [electronic mail protected]: /path/of/binder
-i flag is used to authenticating the connection using a cryptographic central 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 compress the information that you 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-fault bulletin 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 advice, transferring files, port scanning, and network troubleshooting, etc. Information technology comes pre-installed in many Linux-based systems, and it is mainly used by Network Administrators.
If non 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 any port, eastward.g.(port 4747), and type the path of the file y'all want 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 will employ less than sign in the command '<' while the receiving computer will have '>' in the netcat control.
You can besides transfer directories. Fix the receiving host to mind on a port, east.yard. (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 exist transferred. To close the connection, press CTRL+C
Transfer Files Using FTP
FTP (file transfer protocol) is used to transfer files betwixt 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. Information technology allows you to transfer multiple files and directories, and if there is any intermission in the connection during the transfer, the file volition non be lost. Instead, information technology will resume transferring where it got dropped.
Y'all can install an FTP server similar vsftpd using apt by running this command.
$ sudo apt install -y vsftpd
After the package has been installed, y'all have to kickoff the service by typing.
$ sudo systemctl showtime vsftpd
$ sudo systemctl enable vsftpd
Then you tin can connect to the FTP server by typing the control FTP and the IP address.
It will inquire yous the username and password of the FTP server. After you have entered the username and password, you will be connected to your FTP server.
You lot tin list out all the contents of the server by executing this control.
Download via FTP
If you want to download any file from the FTP server, then you lot tin get it by typing the command.
The file will exist downloaded. You lot can also utilise unlike wildcards to download multiple files in a directory. For case ;
Information technology will download all the files with the extension ".html" .
You can besides fix a local directory for downloaded files from the FTP server by using the lcd command.
ftp> lcd /home/user/directory-name
Upload files via FTP
To upload files on the FTP server, type the post-obit command.
ftp> put path/of/local/file
The file volition be uploaded to the FTP server. To upload multiple files, type commands.
It will 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, yous tin only download files.
If you don't take the python installed, and then type the following command.
$ sudo apt install -y python3
To turn on the python server, use the command.
$ sudo python3 -one thousand http.server 4747 #[port e.g.(4747)]
Now 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 folio will open containing all the files and directory on the python server. Yous can go into whatsoever directory and download the files.
You tin go into whatsoever directory and download whatsoever file.
Conclusion
SCP, Netcat, FTP, and Python are unremarkably used methods to transfer files. All of the above methods of transferring files and directories are fast, reliable, and used in modern days. At that place are a lot of other techniques likewise; you lot can prefer any method you adopt.
Source: https://linuxhint.com/linux-server-file-transfer/
Posted by: labontecrind1971.blogspot.com
0 Response to "How To Upload Files To A Fedora Server"
Post a Comment