SSH key : “Permissions 0644 for ' id_rsa. pub' 太开放了。”在苹果机上

标签 ssh permissions key

我在我的 mac 上生成了一个 ssh key 对并将公钥添加到我的 ubuntu 服务器(实际上,它是我的 mac 上的虚拟机),但是当我尝试登录 ubuntu 服务器时,它显示:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/tudouya/.ssh/vm/vm_id_rsa.pub' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /Users/tudouya/.ssh/vm/vm_id_rsa.pub
Permission denied (publickey,password).

我尝试了很多方法来解决这个问题,更改 key 文件模式,更改文件夹模式,如stackoverflow上的一些答案,但它不起作用。
关键文件权限:

vm dir:
drwxr-xr-x   4 tudouya  staff    136  4 29 10:37 vm

key file:
-rw-------  1 tudouya  staff  1679  4 29 10:30 vm_id_rsa
-rw-r--r--  1 tudouya  staff   391  4 29 10:30 vm_id_rsa.pub

请给我一些想法... ===========================================

我将主机信息写入 ssh_config:

Host ubuntuvm
    Hostname 10.211.55.17
    PreferredAuthentications publickey
    IdentityFile /Users/tudouya/.ssh/vm/vm_id_rsa.pub

我运行命令“ssh -v ubuntuvm”,它显示:

ssh -v ubuntuvm
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 103: Applying options for *
debug1: /etc/ssh_config line 175: Applying options for ubuntuvm
debug1: Connecting to 10.211.55.17 [10.211.55.17] port 22.
debug1: Connection established.
debug1: identity file /Users/tudouya/.ssh/vm/vm_id_rsa.pub type 1
debug1: identity file /Users/tudouya/.ssh/vm/vm_id_rsa.pub-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-8
debug1: match: OpenSSH_6.6.1p1 Ubuntu-8 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 55:6d:4f:0f:23:51:ac:8e:70:01:ec:0e:62:9e:1c:10
debug1: Host '10.211.55.17' is known and matches the RSA host key.
debug1: Found key in /Users/tudouya/.ssh/known_hosts:54
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/tudouya/.ssh/vm/vm_id_rsa.pub
debug1: Server accepts key: pkalg ssh-rsa blen 279
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/tudouya/.ssh/vm/vm_id_rsa.pub' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /Users/tudouya/.ssh/vm/vm_id_rsa.pub
debug1: No more authentication methods to try.
Permission denied (publickey,password).

最佳答案

我建议你这样做:

chmod 400 ~/.ssh/id_rsa

对我来说效果很好。

关于SSH key : “Permissions 0644 for ' id_rsa. pub' 太开放了。”在苹果机上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29933918/

相关文章:

mysql - 即使外键为空,如何获取结果集?

c - 通过 SSH 使用 Eclipse 处理远程项目

linux - EC2 ssh broken pipe 终止正在运行的进程

Java:在不需要管理权限的情况下在哪里编写配置

php - 为 WordPress 上传文件的权限问题

Android 运行时权限 - 用户撤销权限时应用程序崩溃。如何处理?

javascript - 在javascript中获取keydown上的字母数字字符

compact-framework - 另一个应用程序可以使用 RSACryptoServiceProvider 访问存储在 key 容器中的私钥吗?

shell - 在每个文本文件的顶部和底部添加新行

linux - 在网络服务器上设置 Linux 机器