因为机器是云服务器(按需那种),就不涂掉IP了
一,修改/etc/ssh/sshd_config文件
#启用密钥登陆
PubkeyAuthentication yes
#关闭密码登陆
PasswordAuthentication no
#修改完成需要重新启动sshd
systemctl restart sshd
二,创建ROOT的密钥对(默认回车即可)
Enter file in which to save the key (/root/.ssh/id_rsa): #密钥对存放路径 默认回车即可
Enter passphrase (empty for no passphrase): #是否给密钥对创建密码 默认回车 不创建
Enter same passphrase again:
三,传输密钥对给xshell
将id_rsa的内容复制一遍。使用windows文本文档打开,并改名为id_rsa 即可
将id_rsa导入xshell
登陆ROOT用户
四,创建普通用户,并创建普通用户登陆的密钥
#创建普通用户usera
useradd usera
#切换到usera用户
su - usera
#给uesra创建密钥对
ssh-keygen
将密钥改个名,好区分
将id_usera_rsa的内容复制一遍。使用windows文本文档打开,并改名为id_usera_rsa 即可
将密钥对导入xshell
登陆usera用户