- How to Upload Files to a Linux VPS from Windows?
- How to Upload Files to a Linux VPS from Windows?
- Conclusion
- Копирование файлов через SSH
- Копирование файлов по SSH на Linux
- Как скопировать файл по SSH с локальной машины на удалённый сервер
- Как скопировать файлы с удалённого сервера на локальный компьютер
- Как скачать папку со всеми файлами и подпапками
- Как подключиться к серверу по нестандартному порту
- Как передать и скачать файлы по SSH на Windows
- Как использовать команду FTP для передачи файлов в Linux
- How to Use Linux FTP Command to Transfer Files
- В этом руководстве мы покажем вам, как использовать команду Linux ftp на практических примерах.
- Прежде чем вы начнете
- Установление FTP-соединения
- Общие команды FTP
- Загрузка файлов с помощью ftp команды
- Загрузка файлов с помощью команды FTP #
- Вывод
- Transfer Files From Computer to Cloud Linux Server
- Using SCP (SSH)
- Transfer Files Using Netcat
- Transfer Files Using FTP
- Downloading files using Python
- Conclusion
- About the author
- Usama Azad
How to Upload Files to a Linux VPS from Windows?
In this blog, we will describe the exact steps, with illustrations on how to upload files to a Linux VPS server from a Windows PC.
List of content you will read in this article:
So, you got yourself a Linux VPS for the first time, connected to it, tested it, and everything seems to work just fine. Now you want to transfer some files from your home or work Windows PC to your VPS so you can work on them there, however, it is not as simple as you think. It is well known that working with servers, especially those running a command line interface can be somewhat burdensome.
In this article, we will explain how to upload local files from a Windows-based PC to a Linux VPS (e.g. CentOS, Ubuntu, Debian, etc.). On the other hand, if you want to learn how to transfer files from a Windows PC to a Windows VPS, check out this detailed tutorial.
How to Upload Files to a Linux VPS from Windows?
For the sake of convenience, the Windows PC you are transferring the files from will be referred to as the source and the Linux VPS you are transferring the files to, will be referred to as the destination.
For the purposes of demonstration, we have created a file on the desktop named “test.txt”.
Follow these simple steps to upload files from a Windows computer to the Linux VPS:
Step 1: Open “Run” by pressing the windows key +R on your keyboard at the same time, or by typing run into the search bar.
Step 2: In the opened run window, type cmd and press Enter.
Step 3: Enter the file’s directory by typing cd followed by the file path. (In this case, the file is on the desktop, so we write cd desktop).
Step 4: Use “SCP” command in the same format as shown below to upload the file.
SCP filename.extension username@serveraddress:filepath
- filename.extension: the name of the file and its extension (test.txt in our case)
- username: the username used to connect to the VPS (root in our case)
- serveraddress: the IP address of the VPS
- filepath: the path where you want the file to be copied to (/etc/ssh in our case)
Step 5: If this is your first time connecting to the server, Windows will ask you to accept the security alert. Please do so.
Step 6: Next, you will have to enter the destination server’s password.
And that’s it! Once the correct password has been entered, your file will be uploaded.
To verify that file is transferred, open putty and connect to destination server. Use “Nano” or “vi” editor to open file.
As can be seen in the following image, the file has been uploaded and is available on the server.
Conclusion
Unfortunately, there is no simple drag-and-drop or upload file button on a Linux VPS server, or just about any server in general. In order to be able to do so and manage the VPS, you will need to learn how to use the command-line interface. Nevertheless, once you know how to do it, it is not much more difficult than using your PC for your typical daily tasks.
We hope that with the help of this article you were able to learn how to upload files from a Windows system to a Linux VPS, using only a single command. If you have any questions or suggestions, please leave them in the comment section down below.
Источник
Копирование файлов через SSH
В статье мы расскажем, как копировать файлы в Windows и Linux-системах, и покажем основные команды, с помощью которых происходит передача файлов по SSH.
Для копирования файлов по SSH в Linux-системах и Windows используют разные инструменты:
- scp (Secure CoPy) — утилита для безопасного копирования данных между Linux-системами по протоколу SSH. Она входит в состав OpenSSH, поэтому для работы с утилитой не нужно устанавливать дополнительное ПО;
- pscp.exe — утилита для загрузки файлов по SSH в ОС Windows. Она обладает теми же возможностями, что и scp. Утилита входит в состав программы Putty — SSH-клиента для Windows. Скачать программу можно по ссылке.
Копирование файлов по SSH на Linux
Для Linux копирование файлов по SSH происходит с использованием команды scp. С её помощью можно копировать файлы:
- с локального компьютера на удалённый сервер,
- с удалённого сервера на локальный компьютер.
Общий вид команды:
scp [опция] [источник] [получатель]
Как скопировать файл по SSH с локальной машины на удалённый сервер
Как загрузить файл на сервер по SSH? Для этого используйте команду вида:
scp [путь к файлу] [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу]
scp /home/test.txt root@123.123.123.123:/directory
Файл test.txt будет скопирован на хост 123.123.123.123 в директорию «/directory».
Как скопировать файлы с удалённого сервера на локальный компьютер
При подключённом SSH скачать файл на локальный компьютер с удалённого сервера можно с помощью команды:
scp [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу] [путь к файлу]
scp root@123.123.123.123:/home/test.txt /directory
Файл test.txt будет загружен с сервера 123.123.123.123 на локальный компьютер в папку «/directory».
Как скачать папку со всеми файлами и подпапками
Если вы хотите скачать папку со всеми файлами и подпапками, используйте ключ -r:
scp -r [источник] [получатель]
Как подключиться к серверу по нестандартному порту
Бывает, что для подключения по SSH нужно указать нестандартный порт. Без указания порта команда подключается к серверу по стандартному 22 порту. Чтобы указать нестандартный порт, введите команду с ключём -P:
scp -P [источник] [получатель]
scp -P 12345 /home/test.txt root@123.123.123.123:/directory
Эта команда подключается по порту 12345 к серверу 123.123.123.123 и копирует на него файл «test.txt» с локального компьютера в директорию «/directory».
Как передать и скачать файлы по SSH на Windows
Скопировать файл по SSH на сервер можно командой:
pscp [путь к файлу] [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу]
Скачать файл по SSH с сервера командой:
pscp [имя пользователя]@[имя сервера/ip-адрес]:[путь к файлу] [путь к файлу]
Увидеть список папок и файлов на сервере можно через pscp.exe. Для этого введите:
pscp -ls [имя пользователя]@[имя сервера/ip-адрес]:[путь]
Если в пути или в названии файла есть пробелы, используйте кавычки:
pscp “C:\files or docs\file name” root@123.123.123.123:/home
Источник
Как использовать команду FTP для передачи файлов в Linux
How to Use Linux FTP Command to Transfer Files
В этом руководстве мы покажем вам, как использовать команду Linux ftp на практических примерах.
FTP (File Transfer Protocol) — это стандартный сетевой протокол, используемый для передачи файлов в удаленную сеть и из нее.
В большинстве случаев вы будете использовать настольный FTP-клиент для подключения к удаленному серверу и загрузки или загрузки файлов. Однако эта ftp команда полезна, когда вы работаете на сервере без графического интерфейса и хотите передавать файлы по FTP на удаленный сервер или с него.
Прежде чем вы начнете
FTP-трафик не зашифрован. Для безопасной передачи данных используйте SCP или SFTP .
Чтобы иметь возможность передавать файлы, у вас должны быть как минимум права на чтение исходного файла и права на запись в целевой системе.
При передаче больших файлов рекомендуется запускать команду ftp внутри сеанса экрана или tmux .
Каталог, из которого вы запускаете ftp команду, является локальным рабочим каталогом.
Установление FTP-соединения
Чтобы открыть FTP-соединение с удаленной системой, вызовите ftp команду, а затем IP-адрес или имя домена удаленного сервера. Например, чтобы подключиться к FTP-серверу по адресу «192.168.42.77», введите:
Если соединение установлено, появится сообщение с подтверждением, и вам будет предложено ввести имя пользователя FTP, в этом примере имя пользователя FTP linuxize :
После ввода имени пользователя вам будет предложено ввести пароль:
Если пароль правильный, на удаленном сервере появится сообщение с подтверждением и ftp> приглашение.
Если FTP-сервер, к которому вы обращаетесь, принимает анонимные учетные записи FTP, и вы хотите войти в систему как анонимный пользователь, используйте в anonymous качестве имени пользователя и свой адрес электронной почты в качестве пароля.
Общие команды FTP
Большинство команд FTP аналогичны или идентичны командам, которые вы вводите в командной строке Linux.
Ниже приведены некоторые из наиболее распространенных команд FTP
- help или ? — перечислить все доступные команды FTP.
- cd — изменить каталог на удаленной машине.
- lcd изменить каталог на локальной машине.
- ls — перечислить имена файлов и каталогов в текущем удаленном каталоге.
- mkdir — создать новый каталог в текущем удаленном каталоге.
- pwd — распечатать текущий рабочий каталог на удаленном компьютере.
- delete — удалить файл в текущем удаленном каталоге.
- rmdir — удалить каталог в текущем удаленном каталоге.
- get — скопировать один файл с удаленного на локальный компьютер.
- mget — скопировать несколько файлов с удаленного на локальный компьютер.
- put — скопировать один файл с локального на удаленный компьютер.
- mput — скопировать один файл с локального на удаленный компьютер.
Загрузка файлов с помощью ftp команды
После входа в систему текущим рабочим каталогом является домашний каталог удаленного пользователя.
При загрузке файлов с помощью ftp команды они будут загружены в каталог, из которого вы ввели ftp команду.
Если вы хотите загрузить файлы в другой локальный каталог, переключитесь на него с помощью lcd команды.
Допустим, мы хотим скачать файлы в
Чтобы загрузить один файл с удаленного сервера, используйте get команду. Например, чтобы загрузить файл с именем, backup.zip вы должны использовать следующую команду:
Вывод должен выглядеть примерно так:
Чтобы загрузить несколько файлов одновременно, используйте mget команду. Вы можете предоставить список отдельных имен файлов или использовать символы подстановки:
После завершения загрузки файлов с удаленного FTP-сервера закройте соединение с помощью команды bye или quit :
Загрузка файлов с помощью команды FTP #
Чтобы загрузить файл из локального каталога на удаленный FTP-сервер, используйте put команду:
Вывод должен выглядеть примерно так:
Если вы хотите загрузить файл, которого нет в вашем текущем рабочем каталоге, используйте абсолютный путь к файлу.
Чтобы загрузить несколько файлов из локального каталога на удаленный FTP-сервер, выполните mput команду:
При загрузке нескольких файлов команда предложит вам подтвердить каждый файл, который вы хотите загрузить.
По завершении загрузки файлов на удаленный FTP-сервер закройте соединение с помощью bye или quit .
Вывод
Из этого руководства вы узнали, как использовать ftp команду для загрузки и выгрузки файлов на удаленный FTP-сервер.
Источник
Transfer Files From Computer to Cloud Linux Server
- using the SCP command in SSH
- using Netcat
- using FTP
- using Python’s Simple HTTP Server
Using SCP (SSH)
SCP is a utility used to move files and directories securely via SSH. With the SCP command, you can transfer files from your computer 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 most Linux servers, but if not, you can install and enable it using the following steps.
Open the Ubuntu terminal and type.
Upload files via SCP
Scp command follows this pattern
To transfer a file from your computer to a linux server, write these commands
In the above command, first, you have to give the path of the file you want to copy from your computer 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 pattern ([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 password, the file will be 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 you’d want your file to be uploaded.
After running this command, it will require the authentication password of the linux server. Once you have entered the password, then the file will be copied safely to your computer.
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, we can change port 22 to something else, like 2222.
-r flag is used to copy the folder and all of its content.
-i flag is used to authenticating the connection using a cryptographic key pair stored in a file instead of a username and password.
-c flag is used to compress the data that you want to transfer.
-q flag is used to suppress the non-error message and progress meter.
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
To transfer files using Netcat, you have to type these commands. Turn the Netcat server on listening mode on any port, e.g.(port 4747), and type the path of the file you want to send.
Note: The server sending file will use less than sign in the command ‘ ’ in the netcat command.
You can also transfer directories. Set the receiving host to listen on a port, e.g. (4747).
Send it to the receiving host listing on the port.
The directory will be transferred. To close the connection, press 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 there is any interruption in the connection during the transfer, the file will not be lost. Instead, it will resume transferring where it got dropped.
You can install an FTP server like vsftpd using apt by running this command.
After the package has been installed, you have to start the service by typing.
Then you can connect to the FTP server by typing the command FTP and the IP address.
It will ask you 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 can list out all the contents of the server by executing this command.
Download via FTP
If you want to download any file from the FTP server, then you can get it by typing the command.
The file will be downloaded. You can also use different wildcards to download multiple files in a directory. For example ;
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.
Upload files via FTP
To upload files on the FTP server, type the following command.
The file will 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, you can only download files.
If you don’t have the python installed, then type the following command.
To turn on the python server, use the command.
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.
A page will open containing all the files and directory on the python server. You can go into any directory and download the files.
You can go 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 as well; you can adopt any method you prefer.
About the author
Usama Azad
A security enthusiast who loves Terminal and Open Source. My area of expertise is Python, Linux (Debian), Bash, Penetration testing, and Firewalls. I’m born and raised in Wazirabad, Pakistan and currently doing Undergraduation from National University of Science and Technology (NUST). On Twitter i go by @UsamaAzad14
Источник