Osmanthus

空想具現化


  • 首页
  • 归档
  • 分类
  • 标签
  • 关于
  •   

© 2024 Homurax

UV: | PV:

Theme Typography by Makito

Proudly published with Hexo

SSH 密钥登录及问题记录

发布于 2024-01-07 Server  SSH 

其实配置本身没有什么好说的,但是最近遇到了一个 Windows 环境的问题,所以一并记录下。

本地

# 检查本地配置
git config --global --list

# 生成密钥
ssh-keygen -t rsa -C "[email protected]"

# 检查
cat ~/.ssh/id_rsa.pub

# 上传本地 SSH 公钥至远程主机对应的账户下
ssh-copy-id -i ~/.ssh/id_rsa.pub root@ip

server

生成及权限配置:

ssh-keygen

chmod 700 ~/.ssh

chmod 600 ~/.ssh/id_rsa

chmod 644 ~/.ssh/id_rsa.pub

chmod 700 ~/.ssh/authorized_keys

# chmod 600 ~/.ssh/* && chmod 644 ~/.ssh/*.pub && chmod 700 ~/.ssh

核对修改配置文件:

vi /etc/ssh/sshd_config
StrictModes no

AuthorizedKeysFile .ssh/authorized_keys

RSAAuthentication yes

PubkeyAuthentication yes

PermitRootLogin yes

重启服务:

systemctl restart sshd

问题记录

参考:
https://stackoverflow.com/questions/49926386/openssh-windows-bad-owner-or-permissions


以管理员用户身份,在一台 Windows 工作站中配置 SSH 密钥登录时,遇到了如下错误提示:

Authorized users only. All activities may be monitored and reported.
Bad permissions. Try removing permissions for user: {计算机名称}}\\{某用户名称} (S-1-5-21-173106597-1076437316-2087015405-1002) on file C:/Users/admin/.ssh/id_rsa.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'C:\\Users\\admin/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "C:\\Users\\admin/.ssh/id_rsa": bad permissions


解决方式如下。
.ssh(C:\Users\{管理员}\.ssh) - 属性 - 安全(选项卡)- 高级(按钮)页面中:
点击禁用继承,选择第一项(将已继承的权限转换为此对象的显式权限)。
然后在权限条目中删除报错中的提示的一般用户即可。

 上一篇: MySQL 5.7 RPM 包方式安装 下一篇: Jasypt 为 SpringBoot 提供配置文件的加密支持 

© 2024 Homurax

UV: | PV:

Theme Typography by Makito

Proudly published with Hexo