使用 pscp 并获得权限被拒绝
我正在使用 pscp 使用以下命令将文件传输到虚拟 ubuntu 服务器:
pscp test.php user@server:/var/www/test.php
并且出现权限被拒绝的错误。如果我尝试转移到文件夹 /home/user/ 我没有任何问题。
我想这与我使用的用户无权访问文件夹 /var/www/ 有关。当我使用 SSH 时,我必须使用 sudo 来访问 /var/www/ 路径 - 我确实这样做了。
是否可以指定 pscp 应“sudo”传输到服务器,以便我可以访问 /var/www/ 路径并实际上能够将文件传输到此文件夹?
I'm using pscp to transfer files to a virtual ubuntu server using this command:
pscp test.php user@server:/var/www/test.php
and I get the error permission denied. If I try to transfer to the folder /home/user/ I have no problems.
I guess this has to do with that the user I'm using doesn't have access to the folder /var/www/. When I use SSH I have to use sudo to get access to the /var/www/ path - and I do.
Is it possible to specify that pscp should "sudo" transfers to the server so I can get access to the /var/www/ path and actually be able to transfer files to this folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您拥有服务器:
将自己添加到 www-data 组:
并设置正确的权限:
这应该可以解决问题。
If you own the server:
Add yourself to the www-data group:
And set the right permissions:
This should do the trick.
请注意以下事项,当您编写
选项 -G 时,将使指定的用户 () 成为指定的特定组的成员。因此,上述语句将使用户成为 www-data 组的一部分,但会将用户从该用户所属的任何其他组中删除。为了避免这种情况,您必须添加选项 -a 或指定您希望用户加入的所有当前组。我不小心把用户“administrator”从 sudo 组中删除了,因为我不知道这一点。因此,如果您希望指定的用户保留其当前的组成员身份,请编写以下命令。
有关 usermod 命令的更多信息,请访问:
Ubuntu 手册页 - usermod< /a>
Beware of the following that when you write
The option -G will make the specified user () a member of the particular group(s) that are specified. So the above statement will make the user a part of group www-data BUT will remove the user from any other group that the user belongs to. To avoid this you must either add the option -a or specify all the current groups that you want the user to be a part of. I accidently took the user "administrator" out of the sudo group because I didn't know this. So if you want the specified user to keep it's current group membership then write the following command.
For more info regarding the usermod command, visit:
Ubuntu manpages - usermod
我遇到了同样的错误“pscp:无法打开 YourFilePath:权限被拒绝”,
请检查您尝试覆盖的文件的所有权,
如果您无法覆盖它,您将收到此错误。
如果您无法控制远程文件,只需尝试重命名您要移动的文件即可。
I had the same error "pscp: unable to open YourFilePath: permission denied",
check the ownership of the file you are trying to overwrite,
you will get this error if you can't overwrite it,
If you don't have control over the remote file, just simply try to rename the file you are trying to move.