其中 12345 为修改的端口号,可自行修改

sed -i 's/#Port 22/Port 12345/' /etc/ssh/sshd_config &&
sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config &&
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config &&
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config.d/50-cloud-init.conf &&
service sshd restart &&
service sshd status;

设置密码
❗️建议一定要设置足够复杂的密码

passwd