使用SSH客户端从Windows机器传输文件到服务器

huangapple go评论62阅读模式
英文:

Transferring files from windows machine to the server using SSH client

问题

我想将我的文件夹从本地Windows机器传输到远程服务器,但它显示权限被拒绝,因为我正在将文件放在根目录,并且它具有所有权限。

首先,我输入以下命令:ssh root@IP,然后它要求输入密码。我输入了我的密码,然后运行以下命令:scp -r d:\kbt root@IP:/var/www/html/

但接着它要求密码,然后显示权限被拒绝。如果有人能帮忙,请告诉我。查看图片描述

英文:

I want to transfer my folder from my local windows machine to the remote server, but it says permission denied as I'm placing files at root directory, and it have all the permissions

First I place this command ssh root@IP then it says enter you password I entered my password and then I run this command scp -r d:\kbt root@IP:/var/www/html/
But then it ask for the password and then it says permission denied Please help me if anyone can.enter image description here

答案1

得分: 0

以下是已经翻译好的内容:

问题在于首先启动ssh会话。所以当您运行scp时,它会在目标机器上执行。它会以与解释162.246.22.217:/var/www/html相同的方式解释d:\test.txt - 它认为冒号前的d是机器名称。您可以看到,因为它要求输入root@d's password

您需要做的是:

  1. 在Windows机器上运行它,而不是首先启动ssh
  2. 安排它,以便您不需要指定驱动器号D:,因为scp会解释那个冒号。

请尝试从Windows命令行执行以下操作:

pushd d:\
scp -r \kbt root@IP:/var/www/html/

pushd将当前工作目录放在正确的Windows驱动器上,因此您只需使用该驱动器根目录下的路径,而无需使用冒号。

一旦上述scp命令完成,您可以使用ssh命令来检查它们是否放在应该放置的位置。

我对69次登录尝试失败有些担忧,除非您知道这是您自己的操作。

编辑:一些较旧版本的Windows不包括scp - 您可以非常类似地使用Putty的pscp

英文:

The issue here is starting the ssh session first. So when you are running scp it's executing on the destination machine. It's interpreting d:\test.txt in the same way it interprets 162.246.22.217:/var/www/html - It thinks the d bit before the colon is the machine name. You can see that because it asks for root@d's password

What you need to do is:

  1. run it on the Windows machine, without first starting ssh
  2. Arrange it so you don't need to specify the drive letter D: because of how scp interprets that colon.

Try this from your Windows command shell:

pushd d:\
scp -r \kbt root@IP:/var/www/html/

The pushd puts the current working directory on the right Windows drive so you can just use the path from the root of that drive, without needing the colon.

Once the scp command above has completed, you can use the ssh command to check that they're there where they should be.

I'd be a bit concerned about 69 failed login attempts. Unless you know it was you.

Edit: some older versions of Windows don't include scp - You can use pscp from Putty very similarly.

huangapple
  • 本文由 发表于 2023年5月25日 15:43:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76329962.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定