201 字
1 分钟
linux设置ssh密钥登录
ssh配置文件位置:/etc/ssh
1.修改ssh配置文件:/etc/ssh/sshd_config
| 参数 | 代码 |
|---|---|
| 允许root登录 | PermitRootLogin prohibit-password |
| 允许密钥登录 | PubkeyAuthentication yes |
| 禁止密码登录 | PasswordAuthentication no |
| 定时发送心跳包 | ClientAliveInterval 30 |
| 重试次数 | ClientAliveCountMax 3 |
| 日志文件 | SyslogFacility AUTH |
| 日志记录等级 | LogLevel INFO |
2.用软件puttygen生成密钥,将公钥并上传至/opt文件夹
3.创建公钥存放路径:mkdir ~/.ssh
4.公钥安装:cat /opt/c01.pub >> ~/.ssh/authorized_keys
5.重启ssh服务:service sshd restart
其他命令
查看系统登录失败次数:lastb|wc -l
生成密钥对:ssh-keygen -m PEM -t rsa -C "fang523"
生成后的密钥路径:/root/.ssh
甲骨文root登录
复制opc用户密钥至root文件夹
cp -r /home/opc/.ssh/authorized_keys /root/.ssh/authorized_keys编辑文件:/root/.ssh/authorized_keys
将ssh-rsa AAAAB3NzaC前面的内容全部删掉
重启ssh服务即可
linux设置ssh密钥登录
https://www.pidexe.com/posts/linux设置ssh密钥登录/