ssh密钥登陆

设置 SSH 无密码登录

本文介绍如何在 Windows 10 中设置SSH无密码通过密钥登陆LINUX。

设置密钥登陆,需要有一个公钥和一个私钥,公钥存放在服务器上,私钥存放在本地主机上

本地主机:win10 服务器:ubuntu18.04 运行环境:PowerShell

现在开始配置密钥登陆


  1. 配置密钥对参见win10配置密钥对
  2. 复制公钥到服务器
cat ~/.ssh/id_rsa.pub | ssh remote_username@server_ip_address "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
  1. 使用 SSH 密钥登录服务器
    ssh remote_username@server_ip_address
  2. 禁用 SSH 密码身份验证
  3. 使用 SSH 密钥登录远程服务器,以具有 sudo 权限的用户或 root 身份:
    ssh sudo_user@server_ip_address
  4. 修改 /etc/ssh/sshd_config配置文件
    /etc/ssh/sshd_config
    PasswordAuthentication no
    ChallengeResponseAuthentication no
    UsePAM no

完成后,保存文件并重新启动SSH服务
执行该命令sudo systemctl restart ssh

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值