mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
translated
This commit is contained in:
parent
b9d4098589
commit
9cc216007d
@ -1,139 +0,0 @@
|
||||
[#]: subject: "Transfer files and folders from Windows to Linux with PSCP"
|
||||
[#]: via: "https://opensource.com/article/22/10/transfer-files-windows-linux-pscp"
|
||||
[#]: author: "Paul https://opensource.com/users/plaubscher"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
Transfer files and folders from Windows to Linux with PSCP
|
||||
======
|
||||
|
||||
The open source PSCP utility makes it easy to transfer files and folders between Windows and Linux computers.
|
||||
|
||||
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][1].
|
||||
|
||||
### 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.
|
||||
|
||||
- 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][3]). 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.
|
||||
- Open Powershell on your Windows computer using the search bar in the Windows taskbar (type 'powershell` into the search bar.)
|
||||
- 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-servicessh--permanent
|
||||
```
|
||||
|
||||
For more information on firewalls on Linux, read [Make Linux stronger with firewalls][4].
|
||||
|
||||
### 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.
|
||||
- `paul@192.168.1.23` 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.
|
||||
|
||||
### 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.
|
||||
- `paul@192.168.1.23:/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.
|
||||
|
||||
![Image of a file manager.][5]
|
||||
|
||||
### 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][6].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/22/10/transfer-files-windows-linux-pscp
|
||||
|
||||
作者:[Paul][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/plaubscher
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://opensource.com/article/22/10/set-path-powershell
|
||||
[2]: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
|
||||
[3]: http://Opensource.com
|
||||
[4]: https://opensource.com/article/19/7/make-linux-stronger-firewalls
|
||||
[5]: https://opensource.com/sites/default/files/2022-10/Filemanager.pscp_.png
|
||||
[6]: https://opensource.com/tags/edge-computing
|
@ -0,0 +1,139 @@
|
||||
[#]: subject: "Transfer files and folders from Windows to Linux with PSCP"
|
||||
[#]: via: "https://opensource.com/article/22/10/transfer-files-windows-linux-pscp"
|
||||
[#]: author: "Paul https://opensource.com/users/plaubscher"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
使用 PSCP 将文件和文件夹从 Windows 传输到 Linux
|
||||
======
|
||||
|
||||
开源 PSCP 程序可以轻松地在 Windows 和 Linux 计算机之间传输文件和文件夹。
|
||||
|
||||
你是否正在寻找一种将文件从 Windows 计算机快速传输到 Linux 计算机并再次传输回来的方法?开源 PSCP 程序可以轻松传输文件和文件夹,当然它是开源的。
|
||||
|
||||
### 在 Windows 中设置 PATH
|
||||
|
||||
了解如何在 Windows 中设置命令路径可以更轻松地使用 PSCP 等方便的程序。如果你不熟悉该过程,请阅读[如何在 Windows 上设置 PATH][1]。
|
||||
|
||||
### 使用 PSCP
|
||||
|
||||
PSCP(PuTTY 安全复制协议)是一个命令行工具,用于将文件和文件夹从 Windows 计算机传输到 Linux 计算机。
|
||||
|
||||
- 从[网站][2]下载 `pscp.exe`。
|
||||
- 将 `pscp.exe` 移动到 PATH 中的文件夹(例如,如果你按照 [Opensource.com][3] 上的 PATH 教程进行操作,则为 `Desktop\App`)。如果你没有设置 PATH 变量,你也可以将 `pscp.exe` 移动到保存要传输的文件的文件夹中。
|
||||
- 使用 Windows 任务栏中的搜索栏在 Windows 计算机上打开 Powershell(在搜索栏中输入 `powershell`。)
|
||||
- 输入 `pscp –version` 以确认你的计算机可以找到该命令。
|
||||
|
||||
### IP 地址
|
||||
|
||||
在进行传输之前,你必须知道目标计算机的 IP 地址或完全限定域名。假设它是同一网络上的计算机,并且你没有运行 DNS 服务器来解析计算机名称,你可以在 Linux 机器上使用 `ip` 命令找到目标 IP 地址:
|
||||
|
||||
```
|
||||
[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
|
||||
```
|
||||
|
||||
在所有情况下,127.0.0.1 都是计算机仅用于与自身通信的环回地址,因此在此示例中,正确的地址是 192.168.1.23。在你的系统上,IP 地址可能不同。如果你不确定哪个是哪个,你可以连续尝试每个,直到找到正确的(然后在某处写下来!)
|
||||
|
||||
或者,你可以查看路由器的设置,其中列出了通过 DHCP 分配的所有地址。
|
||||
|
||||
### 防火墙和服务器
|
||||
|
||||
`pscp` 命令使用 OpenSSH 协议,因此你的 Linux 计算机必须运行 OpenSSH 服务器软件,并且防火墙必须允许 SSH 流量。
|
||||
|
||||
如果你不确定你的 Linux 机器是否正在运行 SSH,请在 Linux 机器上运行以下命令:
|
||||
|
||||
```
|
||||
[linux]$ sudo systemctl enable--now sshd
|
||||
```
|
||||
|
||||
要确保你的防火墙允许 SSH 流量,请运行以下命令:
|
||||
|
||||
```
|
||||
[linux]$ sudo firewall-cmd --add-servicessh--permanent
|
||||
```
|
||||
|
||||
有关 Linux 上的防火墙的更多信息,请阅读[使用防火墙使 Linux 更强大][4]。
|
||||
|
||||
### 传输文件
|
||||
|
||||
在这个例子中,我有一个名为 `pscp-test.txt` 的文件,我想将它从我的 Windows 计算机上的 `C:\Users\paul\Documents` 传输到我的目标 Linux 计算机主目录 `/_home_/paul`。
|
||||
|
||||
现在你已经有了 `pscp` 命令和目标地址,你可以传输测试文件 `pscp-test.txt`。打开 Powershell 并使用 `dir` 命令切换到示例文件所在的 `Documents` 文件夹:
|
||||
|
||||
PS> dir %USERPROFILE%\Documents\
|
||||
|
||||
现在执行传输:
|
||||
|
||||
```
|
||||
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%
|
||||
```
|
||||
|
||||
这是语法,逐字逐句来:
|
||||
|
||||
- `pscp`:用于传输文件的命令。
|
||||
- `pscp-test.txt` 是你要从 Windows 传输的文件的名称。
|
||||
- `paul@192.168.1.23` 是我在 Linux 计算机上的用户名,以及 Linux 计算机的 IP 地址。你必须将其替换为你自己的用户和目的地信息。请注意,`pscp` 需要目标计算机上的目标路径,而 IP 地址末尾的 `:/home/paul` 指定我希望将文件复制到我的主文件夹。
|
||||
|
||||
对 Linux 计算机进行身份验证后,`pscp-test.txt` 文件将传输到 Linux 计算机。
|
||||
|
||||
### 验证已传输
|
||||
|
||||
在你的 Linux 计算机上,打开终端并使用 `ls` 命令验证文件 `pscp-test.txt` 是否出现在您的主目录中。
|
||||
|
||||
```
|
||||
[linux]$ ls
|
||||
Documents
|
||||
Downloads
|
||||
Music
|
||||
Pictures
|
||||
pscp-test.txt
|
||||
```
|
||||
|
||||
### 从 Linux 系统复制文件
|
||||
|
||||
你不仅限于将文件复制到 Linux 系统。使用 `pscp`,你还可以将文件从 Linux 复制到 Windows。语法是一样的,只是反过来:
|
||||
|
||||
```
|
||||
PS> pscp paul@192.168.1.23:/home/paul/pscp-test.txt %USERPROFILE%\Documents\pscp-win.txt
|
||||
```
|
||||
|
||||
这是语法:
|
||||
|
||||
- `pscp`:用于传输文件的命令。
|
||||
- `paul@192.168.1.23:/home/paul/pscp-test.txt` 是我在 Linux 计算机上的用户名、Linux 计算机的 IP 地址,以及我要复制的文件的路径。
|
||||
- `%USERPROFILE%\Documents` 是我的 Windows 计算机上我要保存文件的位置。 请注意,在将文件复制回我的 Windows 计算机时,我可以给它一个新名称,例如 `pscp-win.txt`,以区别于原始文件。 当然,你不必重命名文件,但对于本演示来说,它是一个有用的快捷方式。
|
||||
|
||||
打开文件管理器以验证 `pscp-win.txt` 文件是否已从 Linux 计算机复制到 Windows `C:\Users\paul\Documents` 下。
|
||||
|
||||
![Image of a file manager.][5]
|
||||
|
||||
### 远程复制
|
||||
|
||||
借助开源 `pscp` 命令的强大功能,你可以访问家中的任何计算机、拥有帐户的服务器,甚至是移动设备和[边缘设备][6]。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/22/10/transfer-files-windows-linux-pscp
|
||||
|
||||
作者:[Paul][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/plaubscher
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://opensource.com/article/22/10/set-path-powershell
|
||||
[2]: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
|
||||
[3]: http://Opensource.com
|
||||
[4]: https://opensource.com/article/19/7/make-linux-stronger-firewalls
|
||||
[5]: https://opensource.com/sites/default/files/2022-10/Filemanager.pscp_.png
|
||||
[6]: https://opensource.com/tags/edge-computing
|
Loading…
Reference in New Issue
Block a user