栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

【web渗透】私钥ssh远程登录报错:permission 0644 for ‘id

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【web渗透】私钥ssh远程登录报错:permission 0644 for ‘id

1.问题

在用私钥远程ssh登录服务器时,出现报错:

permission 0644 for 'id_rsa' are too open

私钥文件如图:

2.问题分析

❗❗❗
我们看到,上述私钥文件权限给user开了可读写,给group和others开了可读
❗❗❗

我们直接查ssh命令的帮助手册:

man ssh

找到如下描述:

 ~/.ssh/id_rsa
             Contains the private key for authentication.  These files contain sensitive data and should be readable by the user but not accessible by others (read/write/exe‐
             cute).  ssh will simply ignore a private key file if it is accessible by others.  It is possible to specify a passphrase when generating the key which will be used
             to encrypt the sensitive part of this file using 3DES.

     ~/.ssh/identity.pub
     ~/.ssh/id_dsa.pub
     ~/.ssh/id_ecdsa.pub
     ~/.ssh/id_ed25519.pub
     ~/.ssh/id_rsa.pub
             Contains the public key for authentication.  These files are not sensitive and can (but need not) be readable by anyone.

意思是
私钥id_rsa文件过于敏感,只能被文件所有者读,而不能被其他用户读;
公钥id_rsa.pub不是那么敏感,可以让所有人可读

3.解决方案

不赋予任何权限给群组用户和其他用户
赋予文件所有者读或读写(4/6)的权限

chmod 400 id_rsa

chmod 600 id_rsa

成功:

尝试连接

ssh -i id_rsa username@ip


输入密码登录!

但此处按道理不应该输入密码。先挖个坑。

那么,好了,如果id_rsa没有解密密码,可以直接使用,但是如果id_rsa有解密密码,那么就需要进行相应的密码。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/291936.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号