简体   繁体   English

无法使用 Windows 子系统将本地文件 wsl ubuntu 终端传输到远程服务器

[英]Unable to transfer local file wsl ubuntu terminal to remote server using windows subsystem

I have a file called test1.zip in /mnt/c/Users/test/ folder of my local laptop [in which ubuntu windows subsystem for linux is installed].我在本地笔记本电脑的/mnt/c/Users/test/文件夹中有一个名为test1.zip的文件 [其中安装了用于 linux 的 ubuntu Windows 子系统]。 Local ubuntu terminal WSL name is lauda本地 ubuntu 终端 WSL 名称为lauda

Now, I would like to transfer this zip file called test1.zip to my remote server named stuff .现在,我想将这个名为test1.zip zip 文件test1.zip到名为stuff远程服务器。

PLEASE NOTE THAT ALL COMMANDS ARE TRIED FROM MY LOCAL LAPTOP WSL SCREEN [ubuntu screen]请注意,所有命令都在我的本地笔记本电脑 WSL 屏幕 [ubuntu 屏幕] 上尝试过

So, I tried the below command from my WSL [local laptop ubuntu WSL terminal]所以,我从我的 WSL [本地笔记本电脑 ubuntu WSL 终端] 尝试了以下命令

scp user1@lauda:/mnt/c/Users/test/test1.zip user1@stuff:/home/test/codes/test1

and got the error ssh: Could not resolve hostname lauda: Name or service not known并收到错误ssh: Could not resolve hostname lauda: Name or service not known

So I tried the below [replacing the lauda local laptop ubuntu terminal hostname with its IP]所以我尝试了下面的 [用它的 IP 替换lauda本地笔记本电脑 ubuntu 终端主机名]

scp user1@172.xx.xxx.xxx:/mnt/c/Users/test/test1.zip user1@stuff:/home/test/codes/test1

this resulted in error as ssh: connect to host 172.xx.xxx.xxx port 22: Connection refused这导致错误为ssh: connect to host 172.xx.xxx.xxx port 22: Connection refused

Now I tried the same command as above but in opposite way as shown below现在我尝试了与上面相同的命令,但以相反的方式如下所示

scp user1@stuff:/home/test/codes/ user1@lauda:/mnt/c/Users/test/test1.zip

and got the below error并得到以下错误

ssh: Could not resolve hostname lauda: Temporary failure in name resolution

Later, I tried with IP address后来,我尝试使用IP地址

 scp user1@stuff:/home/test/codes/ user1@172.xx.xxx.xxx:/mnt/c/Users/test/test1.zip

And I got the below error我得到了以下错误

ssh: connect to host 172.xx.xxx.xxx port 22: No route to host lost connection

Later, I tried the below commands as well后来,我也尝试了以下命令

scp /mnt/c/Users/test/test1.zip user1@stuff:/home/test/codes/

and got an error scp: /home/test/codes/test1.zip: Permission denied并得到一个错误scp: /home/test/codes/test1.zip: Permission denied

So, I again tried like below所以,我再次尝试如下

scp user1@stuff:/home/test/codes/ /mnt/c/Users/test/test1.zip 

and got an error scp: /home/test/codes: not a regular file并得到一个错误scp: /home/test/codes: not a regular file

PLEASE NOTE THAT ALL COMMANDS ARE TRIED FROM MY LOCAL LAPTOP WSL SCREEN [ubuntu screen]请注意,所有命令都在我的本地笔记本电脑 WSL 屏幕 [ubuntu 屏幕] 上尝试过

How can I transfer local files/folders from my local ubuntu WSL terminal to remote server?如何将本地文件/文件夹从本地 ubuntu WSL 终端传输到远程服务器?

scp /mnt/c/Users/test/test1.zip user1@stuff:/home/test/codes/ is the closest attempt to working. scp /mnt/c/Users/test/test1.zip user1@stuff:/home/test/codes/是最接近工作的尝试。 The error you get could be due to one of two reasons:您得到的错误可能是由于以下两个原因之一:

Firstly user1 does not have permissions to write to /home/test on stuff - makes sense as usually only the test user would be able to write there.首先, user1没有权限写入/home/teststuff - 通常只有test用户才能在那里写入是有道理的。 (Note that the test user on your WSL instance is not the same profile the test user on the remote.) (请注意, test你的WSL实例用户是不一样的配置文件中的test遥控器上的用户。)

Secondly the /home/test/codes/ folder may not even exist yet.其次, /home/test/codes/文件夹甚至可能还不存在。

Instead (if you know test 's password) copy as the test user :相反(如果您知道test的密码)复制为test用户:

scp /mnt/c/Users/test/test1.zip test@stuff:/home/test/codes/

Or copy to user1 's home directory (after ensuring you have created /home/user1/codes/或者复制到user1的主目录(确保你已经创建了/home/user1/codes/

scp /mnt/c/Users/test/test1.zip user1@stuff:/home/user1/codes/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法连接到服务器:Linux 的 Windows 子系统中 ubuntu 上的 postgresql - Unable to connect to server: postgresql on ubuntu in windows subsystem for linux 从 local.network 访问运行在 WSL(Linux 的 Windows 子系统)上的 web 服务器 - Access a web server which is running on WSL (Windows Subsystem for Linux) from local network 是否可以在Windows Subsystem for Linux(WSL)-Ubuntu上安装IBM Java? - Is it possible to install IBM java on Windows Subsystem for Linux (WSL) - Ubuntu? 从 Sublime Text 使用 Windows Subsystem for Linux (WSL) - Using Windows Subsystem for Linux (WSL) from Sublime Text 如何在 WSL 中使用 Ubuntu 卸载繁忙的 windows 文件? - How to umount a busy windows file using Ubuntu in WSL? 使用 Ubuntu WSL 和 Zsh 在 Windows 终端中打开选项卡 - Open tabs in Windows Terminal w/ Ubuntu WSL & Zsh 尝试将文件从本地 Mac 上传到远程 Ubuntu 服务器 - Trying to upload a file from local Mac to remote Ubuntu server 在 Windows 上使用 Ubuntu 的子系统进行“make”会导致 java 错误 - Using Ubuntu's subsystem on Windows for 'make' gives java error 使用 gitbash 终端将文件从 windows 10 移动到 ubuntu 文件夹 - Move file from windows 10 to ubuntu folder using gitbash terminal 无法在Windows子系统Linux上使用gdb在VS代码上调试C - Unable to debug C on VS Code using gdb on Windows Subsystem for Linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM