Skip to content

ssh

安装 ssh server

https://cloud.tencent.com/developer/article/1638882

sh
sudo apt update
sudo apt install openssh-server

检查 ssh 是否启动

sh
sudo systemctl status ssh
sudo systemctl start ssh
sh
sudo ufw allow ssh

如果遇见无法登录的情况 vim /etc/ssh/sshd_config

PermitRootLogin prohibie-password 修改为:PermitRootLogin yes

sh
sudo systemctl restatus ssh

还有检查用户名大小写的问题!

修改 ssh 端口

sh
vim /etc/ssh/sshd_config.d/port-override.conf
sh
# 确保有这个配置文件
Include /etc/ssh/sshd_config.d/*.conf

Port 2222

检查配置是否生效

sh
sshd -T | grep port

防火墙

sh
sudo ufw allow 2222/tcp

重启 ssh 服务

sh
sudo systemctl restart ssh