Skip to content

Eternal Center

  • System (系统)
  • Services (服务)
  • Databases (数据库)
  • Clusters (集群)
  • Big Data (大数据)
  • Cloud Computing (云计算)
  • Languages (语言)
  • Project (项目)
  • Writings (写作)
  • Eternity (永恒)
  • News (消息)
  • Chronicle (编年史)
  • Words (言)
Posted on May 9, 2020April 29, 2022 by Mingyu Zhu

[步骤] Linux 登陆安全的实现 (通过复杂 SSH 公私密钥实现)

步骤目录:

步骤一:生成复杂的 SSH 密钥
步骤二:将生成的复杂 SSH 密钥移动到指定位置
步骤三:给部署好的复杂 SSH 密钥设置权限
步骤四:将复杂的 SSH 公钥拷贝到目标服务器
步骤五:指定复杂 SSH 密钥登陆目标服务器
步骤六:在目标服务器上设置只能使用密钥登陆

补充:
补充一:修改复杂 SSH 密钥密码的方法
补充二:显示已生成的 SSH 密钥的加密方式

具体的步骤:

步骤一:生成复杂的 SSH 密钥

# ssh-keygen -b 4096 -t rsa -C "<content>" -f "<public private key name>"

(注意:在生成复杂 SSH 密钥的时候最好也设置它的使用密码)

步骤二:将生成的复杂 SSH 密钥移动到指定位置

# mv <public private key name>* ~/.ssh/

步骤三:给部署好的复杂 SSH 密钥设置权限

# chmod -R 600 ~/.ssh/<public private key name>*

步骤四:将复杂的 SSH 公钥拷贝到目标服务器

# ssh-copy-id -i ~/.ssh/<public private key name>.pub <destination IP address>

步骤五:指定复杂 SSH 密钥登陆目标服务器

# ssh -i ~/.ssh/<public private key name> <destination IP address>

步骤六:在目标服务器上设置只能使用密钥登陆

# vim /etc/ssh/sshd_conf

将其中的:

......
# PasswordAuthentication yes
......
# ChallengeResponseAuthentication yes
......

修改为:

......
PasswordAuthentication no
......
ChallengeResponseAuthentication no
......

补充:

补充一:修改复杂 SSH 密钥密码的方法

# ssh-keygen -p -f ~/.ssh/<public private key name>

(补充:无密码的 SSH 密钥也能通过此方法设置密码)

补充二:显示已生成的 SSH 密钥的加密方式

# ssh-keygen -l -f ~/.ssh/<public private key name>
CategoriesChinese (中文), System (系统), System Login Security (系统登录安全), System Network & System Security & System Log (系统网络 & 系统安全 & 系统日志), System Operation & System Setting & System Software (系统操作 & 系统设置 & 系统软件), System Port Security (系统端口安全), System Security (系统安全), System Setting (系统设置)

Post navigation

Previous PostPrevious [实验] Linux Django 项目的制作 (PyCharm 版)
Next PostNext [命令] Linux 命令 passwd (管理密码)

Aspiration (愿景):

Everyone can achieve self achievement and self happiness fairly

每个人都能公平地实现自我成就和自我幸福

Position (位置):

Running on Evolution Host and DigitalOcean

正在 Evolution Host 和 DigitalOcean 上运行

Logo (徽标):

Additional Information (其他信息):

About Manual Clone Contact Disclaimer Donation Friendly Links 关于 说明书 克隆 联系 免责申明 捐赠 友情链接

Standby IP Address (备用 IP 地址):

152.69.204.95  150.230.63.10  Please configure before use / 请先配置再使用

Search Outside Website (站外搜索):

Google Wikipedia Bing
Proudly powered by LNMP Proudly powered by WordPress