Linux7设置ssh秘钥登录并关闭密码登录

说明:场景为windows使用WinScp远程登录linux服务

winscp安装教程:winscp安装及关联putty使用_putty.exe没有找到_cherishSpring的博客-CSDN博客

1.在window上生成公钥和秘钥,操作方式参考以下文章第3点:

git关联云效使用教程_云效怎么绑定git账号-CSDN博客

​​​​​​生成文件如下

2.将id_rsa.pub文件上传到linux服务器.ssh目录

复制代码
cd /root
mkdir .ssh
  1. 配置sshd_config文件

    cat id_rsa.pub>>authorized_keys #将公钥写进文件
    vim /etc/ssh/sshd_config #编辑sshd_config文件,按i进入编辑模式

    #以下配置有则修改,无则空白处添加
    PasswordAuthentication no #关闭密码登录
    RSAAuthentication yes #使用RSA加密算法
    PubkeyAuthentication yes #打开密钥输入模式
    PermitRootLogin yes #允许root远程登陆

    #允许的公钥存放的文件,普通用户需要在主目录下再存放一份.ssh文件并在此配置
    AuthorizedKeysFile .ssh/authorized_keys /home/app/.ssh/authorized_keys

    按esc
    输入:wq保存退出

    systemctl restart sshd #重启ssh服务

4.使用winscp以ssh方式远程访问服务,高级->SSH->验证->选择密钥文件

相关推荐
db_murphy13 小时前
学习篇 | 服务器的睿频
运维·服务器·学习
Levin__NLP_CV_AIGC13 小时前
Ubuntu部署Dufs
linux·运维·服务器·ubuntu·ssh
cly113 小时前
Ansible自动化(八):条件语句
运维·自动化·ansible
MrYang202013 小时前
Vcenter vsphere 登录报错
运维·vmware
suamt13 小时前
记录windows下如何运行docker程序
运维·docker·容器
小宇的天下13 小时前
Calibre 3Dstack --每日一个命令days8【connected】(3-8)
运维·服务器·性能优化
切糕师学AI13 小时前
SSH是什么?
ssh
ICT系统集成阿祥13 小时前
服务器网卡绑定(bond)7种模式详解
运维·服务器·bond·网卡绑定·服务器链路聚合
wulalalalalalalal13 小时前
Linux 内网服务器通过代理访问外网
linux·运维·服务器
C_心欲无痕13 小时前
ts - 模板字面量类型与 `keyof` 的魔法组合:`keyof T & `on${string}`使用
linux·运维·开发语言·前端·ubuntu·typescript