我正在尝试在 Windows 中使用 OpenSSH 连接到 Amazon EC2,但我需要设置我的密钥文件的权限。
windows相当于CHMOD 600
什么?
我已经广泛搜索并发现只有博客垃圾邮件。
编辑:Windows 7,使用 DOS。
我正在尝试在 Windows 中使用 OpenSSH 连接到 Amazon EC2,但我需要设置我的密钥文件的权限。
windows相当于CHMOD 600
什么?
我已经广泛搜索并发现只有博客垃圾邮件。
编辑:Windows 7,使用 DOS。
我意识到这有点老了,但我刚刚在 Windows 7 中为自己找到了解决方案。看起来这个问题没有得到解决。我有所有相同的错误,包括你Cygwin missing cygintl-2.dll
在chmod
评论中提到的。
经过广泛的研究并没有找到任何答案,我跑了:
C:\Users\mztriz\.ssh>ssh -v
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_file] [ -L 端口:主机:主机端口] [-l 登录名] [-m mac_spec] [-o 选项] [-p 端口] [-R 端口:主机:主机端口] [用户@]主机名 [命令]
如您所见,我运行的 OpenSSH 版本已经过时了。但是,我不知道这一点,因为快速谷歌搜索会 OpenSSH for Windows
返回这个旧版本。
在查看版本控制后,我在该网站的下载部分找到了适用于 Windows 6.9p1-1 的 OpenSSH 。
这个较新版本的 OpenSSH 似乎解决了您提到的所有问题。
右键单击文件/目录,选择属性,然后选择安全。单击高级,然后单击编辑。取消选中“可继承”并在对话框中选择“删除”。删除任何剩余的显式权限,为您的用户名添加“完全访问”权限。
修改权限,以便:
现在 scp 将读取权限 0400 并且会很高兴。伊什。
很简单:
chown -R $USER:users ~/.ssh/
chmod -R 600 ~/.ssh/
如果该文件是 Windows (NTFS) 符号链接,则上述内容将不起作用。您需要将其设为常规文件。我不确定为什么。
如果您没有 openssh 或 cygwin,请使用 Chocolatey 使用Chocolatey轻松安装它。
choco install cyg-get
打开安装了巧克力的 Cygwin 终端并运行(注意ssh-keygen
创建新密钥):
cyg-get install openssh
ssh-keygen
cd ~/.ssh && explorer.exe .
验证密钥是否存在(或用您想要的密钥替换它们),然后在 Cygwin shell 中:
chown -R $USER:users ~/.ssh/
chmod -R 600 ~/.ssh/
或者对于您正在使用(并从中生成密钥)chocolatey 的 SSH包的罕见情况:
chown -R $USER:users /cygdrive/c/Users/$USER/.ssh
chmod -R 600 /cygdrive/c/Users/$USER/.ssh
我有同样的问题。有效的解决方案是将 ssh.exe 的兼容模式设置为 Windows XP SP3。
我更喜欢Cygwin而不是putty,您可以在 cygwin 中运行 chmod 命令将 PEM 密钥的权限更改为 400,然后就可以了。
myuser@myuser-HP ~
$ ssh -i /cygdrive/c/Users/myuser/Downloads/mykey.pem ec2-user@xx.xx.xx.xx
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 ec2-user@xx.xx.xx.xx
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-ami/2015.09-release-notes/
[ec2-user@ip-xxx ~]$ ohyeah I am in!
chmod 在 Windows 中不起作用。尝试以下方法限制访问
今天在 Windows 上推荐的方法之一是使用 PowerShellGet-Acl
和Set-Acl
Cmdlet。
这是一个确保只有当前用户有权访问文件夹及其中所有文件的示例 - 类似于.ssh
Unix/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
有关更多详细信息,请参阅
我有同样的问题。有效的解决方案是将 ssh.exe 的兼容模式设置为 Windows XP SP3。
-> 这个答案适用于 Windows 7
没有真正回答同样的问题,但我能够使用这些说明连接到 EC2:
通过 scp 将文件复制到 Unix 系统并将 chmod 600 设置为文件。然后将文件传输回 Windows 机器。它对我有用。