1.首先确认客户端与服务端能相互ping通
2.新装的服务器可能没有安装sshd,查看是否安装
systemctl status sshd
若提示 not be found 则没有安装,建议先更新源再安装
apt update
apt install -y openssh-server
安装完成后启动sshd,查看状态
systemctl start sshd
systemctl status sshd
3.还有个问题:Ubuntu默认是只能使用普通用户ssh连接后再用 su 命令转到root用户(首次登录Ubuntu默认是普通用户,要使用root用户需要sudo root passwd 为其设置密码)。
修改配置文件可以让root用户远程登录
vi /etc/ssh/sshd_config
···
#PermitRootLogin prohibit-password
PermitRootLogin yes //新加一行或将上面注释去掉后面更改为yes
···
重启sshd后就可以用root用户直接登录了
systemctl restart sshd