windows 视窗 CHMOD 600

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5264595/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:10:25  来源:igfitidea点击:

Windows CHMOD 600

windowspermissionssshssh-keys

提问by Austin Richardson

I'm trying to connect to Amazon EC2 using OpenSSH in windows but I need to set the permissions of my key file.

我正在尝试在 Windows 中使用 OpenSSH 连接到 Amazon EC2,但我需要设置我的密钥文件的权限。

What is the windows equivalent of CHMOD 600?

窗户相当于CHMOD 600什么?

I've googled extensively and found only blogspam.

我在谷歌上广泛搜索,只找到了博客垃圾邮件。

EDIT: Windows 7, using DOS.

编辑:Windows 7,使用 DOS。

采纳答案by Austin Richardson

Not really answering the same question but I was able to connect to EC2 using these instructions:

没有真正回答相同的问题,但我能够使用以下说明连接到 EC2:

SSH to EC2 linux instance from Windows

从 Windows SSH 到 EC2 linux 实例

回答by ???

I realize this is somewhat old but I just found the solution for myself in Windows 7. And it looks like this question went unresolved. I had all of the same errors including Cygwin missing cygintl-2.dllon chmodas you noted in the comments.

我意识到这有点旧,但我刚刚在 Windows 7 中为自己找到了解决方案。看起来这个问题没有解决。我把所有的同样的错误,包括Cygwin missing cygintl-2.dllchmod你的评论中指出。

After extensive research and not finding any answers I ran:

经过广泛的研究并没有找到任何答案,我跑了:

C:\Users\mztriz\.ssh>ssh -v

OpenSSH_3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004 usage: ssh [-1246AaCfghkNnqsTtVvXxY] [-b bind_address] [-c cipher_spec] [-D port] [-e escape_char] [-F configfile] [-i identity_file] [-L port:host:hostport] [-l login_name] [-m mac_spec] [-o option] [-p port] [-R port:host:hostport] [user@]hostname [command]

OpenSSH_3.8.1p1、OpenSSL 0.9.7d 2004 年 3 月 17 日用法:ssh [-1246AaCfghkNnqsTtVvXxY] [-b bind_address] [-c cipher_spec] [-D port] [-e escape_char] [-F configfile] [-i identity_xY] -L port:host:hostport] [-l login_name] [-m mac_spec] [-o option] [-p port] [-R port:host:hostport] [user@]hostname [command]

As you can see the version of OpenSSH I was running was quite outdated. However, I didn't know this because a quick google search of OpenSSH for Windowsreturns this old version.

正如您所看到的,我运行的 OpenSSH 版本已经过时了。但是,我不知道这一点,因为在谷歌上快速搜索会 OpenSSH for Windows返回这个旧版本。

After looking into the versioning I found OpenSSH for Windows 6.9p1-1in the downloads section of that website.

在查看版本控制后,我在该网站的下载部分找到了适用于 Windows 6.9p1-1 的 OpenSSH

This newer version of OpenSSH seems to fix all of the issues you mention.

这个较新版本的 OpenSSH 似乎解决了您提到的所有问题。

回答by user2309219

Modify the permissions so that:

修改权限,以便:

  • The key file doesn't inherit from the container
  • You (the owner) have full access
  • Remove permission entries for any other users (e.g., SYSTEM, Administrator)
  • Add an Entry for special user Everyoneand edit the permissions for that user to Deny for all permissions:
    • Right click on the file in Windows Explorer and choose Properties > Security > Advanced, to get the Advanced Security Settings dialog.
    • Click on the Permissions tab, then click Change Permissions.
    • Click Add, enter Everyone into the object name field, click Check Names, then click OK.
    • In the Permission Entry dialog, click the checkbox in the Deny column for Full Control.
    • Click OK on each dialog to back out and close the file's properies dialog.
  • 密钥文件不是从容器继承的
  • 您(所有者)拥有完全访问权限
  • 删除任何其他用户的权限条目(例如,SYSTEM、管理员)
  • 为特殊用户“所有人”添加一个条目,并将该用户的权限编辑为拒绝所有权限:
    • 在 Windows 资源管理器中右键单击该文件,然后选择“属性”>“安全”>“高级”,以获取“高级安全设置”对话框。
    • 单击权限选项卡,然后单击更改权限。
    • 单击“添加”,在对象名称字段中输入“所有人”,单击“检查名称”,然后单击“确定”。
    • 在“权限条目”对话框中,单击“完全控制”的“拒绝”列中的复选框。
    • 在每个对话框上单击确定以退出并关闭文件的属性对话框。

Now scp will read permissions 0400 and will be happy. Ish.

现在 scp 将读取权限 0400 并且会很高兴。伊什。

回答by Erik

Right-click on the file/dir, select Properties then Security. Click Advanced, then Edit. Uncheck "Inheritable" and choose "Remove" in the dialog. Remove any explicit permissions left, add a "Full Access" permission to your username.

右键单击文件/目录,选择属性,然后选择安全性。单击高级,然后单击编辑。取消选中“可继承”并在对话框中选择“删除”。删除剩余的任何显式权限,为您的用户名添加“完全访问”权限。

回答by Ralfeus

I've go same issue. The solution, which worked was to set compatibility mode of ssh.exe to Windows XP SP3.

我去了同样的问题。有效的解决方案是将 ssh.exe 的兼容模式设置为 Windows XP SP3。

回答by Erin

I ran into the same problem on windows 10. I fixed it by adding my user and granting the Modify, Read & execute, Read and write permissions. I removed all other users. Here is what it looks like after removing all other permissions:

我在 Windows 10 上遇到了同样的问题。我通过添加我的用户并授予修改、读取和执行、读取和写入权限来修复它。我删除了所有其他用户。这是删除所有其他权限后的样子:

enter image description here

在此处输入图片说明

回答by B.Mr.W.

I prefer Cygwinover puttyand you can just run chmod command in cygwin to change the permission of PEM key to be 400, then you are good to go.

我更喜欢Cygwin 而不是Putty,你可以在 cygwin 中运行 chmod 命令将 PEM 密钥的权限更改为 400,然后你就可以开始了。

myuser@myuser-HP ~
$ ssh -i /cygdrive/c/Users/myuser/Downloads/mykey.pem [email protected]
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0550 for '/cygdrive/c/Users/myuser/Downloads/mykey.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/cygdrive/c/Users/myuser/Downloads/mykey.pem": bad permissions
Permission denied (publickey).

myuser@myuser-HP ~
$ chmod
chmod: missing operand
Try 'chmod --help' for more information.

myuser@myuser-HP ~
$ chmod 400 /cygdrive/c/Users/myuser/Downloads/mykey.pem

myuser@myuser-HP ~
$ ssh -i /cygdrive/c/Users/myuser/Downloads/meykey.pem [email protected]

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2015.09-release-notes/
[ec2-user@ip-xxx ~]$ ohyeah I am in!

回答by Jonathan

For unix & OSX

对于 Unix 和 OSX

Quite simply:

很简单:

chown -R $USER:users ~/.ssh/
chmod -R 600 ~/.ssh/

For Windows

对于 Windows

If the file is a windows (NTFS) symbolic link, the above won't work. You need to make it a regular file. I am not sure why.

如果文件是 Windows (NTFS) 符号链接,则上述方法无效。您需要将其设为常规文件。我不知道为什么。

If you don't have openssh or cygwin, use chocolatey to install it easily using chocolatey.

如果您没有 openssh 或 cygwin,请使用 Chocolatey 使用Chocolatey轻松安装它。

choco install cyg-get

Open Cygwin Terminalthat was installed with chocolatey and run (note that ssh-keygencreates new keys):

打开安装了 Chocolatey 的Cygwin 终端并运行(注意ssh-keygen创建新密钥):

cyg-get install openssh
ssh-keygen
cd ~/.ssh && explorer.exe .

Verify keys are there (or replace them with the keys you want), and then in Cygwin shell:

验证密钥是否存在(或用您想要的密钥替换它们),然后在 Cygwin shell 中:

chown -R $USER:users ~/.ssh/
chmod -R 600 ~/.ssh/

Or for the rare case that you're using (and generated the keys from) chocolatey's SSHpackage:

或者对于您正在使用(并从中生成密钥)巧克力的 SSH包的罕见情况:

chown -R $USER:users  /cygdrive/c/Users/$USER/.ssh
chmod -R 600 /cygdrive/c/Users/$USER/.ssh

回答by Florian Feldhaus

Today one of the recommended ways on Windows would be to use PowerShell and the Get-Acland Set-AclCmdlets.

今天在 Windows 上推荐的方法之一是使用 PowerShellGet-AclSet-AclCmdlet。

Here's an example to ensure that only the current user has permission to a folder and all files in it - similar to what is recommended for the .sshfolder in Unix/Linux/OS X:

这是一个确保只有当前用户有权访问文件夹及其中所有文件的示例 - 类似于.sshUnix/Linux/OS X 中推荐的文件夹:

# get current ACL of directory
$Acl = Get-Acl -Path $Directory

# remove inheritance ($true) and remove all existing rules ($false)
$Acl.SetAccessRuleProtection($true,$false)

# create new access rule for
# current user
# with FullControl permission
# enable inheritance for folders and files
# enable it for the specified folder as well
# allow these conditions 
$AcessRule = [System.Security.AccessControl.FileSystemAccessRule]::new(
    $env:USERNAME,
    "FullControl",
    ([System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit),
    [System.Security.AccessControl.PropagationFlags]::None,
    [System.Security.AccessControl.AccessControlType]::Allow)

# add access rule to empty ACL
$Acl.AddAccessRule($AcessRule)

# activate ACL on folder
Set-Acl -Path $Directory -AclObject $Acl

For more details see

有关更多详细信息,请参阅

回答by tCheang

I've go same issue. The solution, which worked was to set compatibility mode of ssh.exe to Windows XP SP3.

我去了同样的问题。有效的解决方案是将 ssh.exe 的兼容模式设置为 Windows XP SP3。

-> This answer works for windows 7

-> 此答案适用于 Windows 7