sudo apt updatesudo apt install openssh-serversudo systemctl status ssh,若未运行,使用sudo systemctl start ssh启动sudo systemctl enable sshsudo nano /etc/ssh/sshd_config
Port 22,改为其他端口(如2222)PermitRootLogin yes改为PermitRootLogin noPubkeyAuthentication yes,并确保PasswordAuthentication noAllowUsers your_usernamesudo systemctl restart ssh若启用UFW防火墙,需开放SSH端口:sudo ufw allow ssh,若修改了默认端口,需相应修改为sudo ufw allow 端口号/tcp
在另一台设备上使用ssh username@服务器IP -p 端口号进行连接,若配置正确,输入密码即可登录