以下是在Ubuntu上安装和配置OpenSSH的步骤:
sudo apt update。sudo apt install openssh-server。sudo systemctl start ssh。sudo systemctl enable ssh。sudo systemctl status ssh,若显示“active (running)”,则服务已成功启动。/etc/ssh/sshd_config,例如修改端口号、禁止root登录等:sudo nano /etc/ssh/sshd_config。Port(默认22,可修改)、PermitRootLogin(设为no禁止root登录)、PasswordAuthentication(设为no可禁用密码认证)等。sudo systemctl restart ssh。sudo ufw allow ssh。若修改了默认端口,需使用对应端口号,如sudo ufw allow 2222/tcp。ssh username@server_ip命令连接,将username替换为目标用户名,server_ip替换为服务器IP地址。若修改了端口,使用ssh -p port_number username@server_ip。