云服务器远程SSH连接

修改配置文件/etc/ssh/sshd_config

PermitRootLogin yes
PasswordAuthentication yes

写入root的密码

sudo passwd root
New password: ***(无显示)
Retype new password: ***(无显示)

开放端口22即可在FinalShell或xShell等SSH远程连接工具中输入root和密码***即可

使用密钥对登录服务器

ssh-keygen -t rsa -b 4096

# 输入存储的目录
# 输入密码(建议)
# 默认存储在/root/.ssh/目录下
# 将生成公钥添加至authorized_keys
cat id_rsa.pub > authorized_keys

编辑/etc/sshd_config,强烈建议修改默认的22端口为其他端口号

Port *
PasswordAuthentication no
PubkeyAuthentication yes

注意:在/etc/ssh/sshd_config.d/下还有默认的配置有允许通过密码登录的配置,也需要改为no