环境
系统:Ubuntu 18.04.6 LTS
IP:192.168.1.4
ps:查看ubuntu版本
bash
lsb_release -a

查看ubuntu的ip地址
Ubuntu系统准备工作
root权限
打开ubuntu系统后,打开终端,切换为root权限:su root

如果出现su root认证失败的情况是因为root用户默认锁定的,只要使用passwd命令重新设置下root密码即可。

终端输入sudo passwd,根据提示修改密码

输入su,输入修改后的密码即可切换到root用户

查看端口
查看22端口是否开启。如果22端口没开是无法进行远程连接的。
bash
netstat -ntlp|grep 22
出现xxx:22说明开启,否则需要手动开启
退出root权限 su user(user是你自己的用户名)

1)安装SSH服务器
bash
sudo apt-get install openssh-server

2)安装配置和管理防火墙工具UFW
bash
sudo apt-get install ufw

3)启用防火墙
bash
sudo ufw enable

4)允许通过SSH协议访问系统
bash
sudo ufw allow 22

Xshell创建连接

点击【连接】按钮,出现下面界面表示连接成功

操作时和在ubuntu上操作相同
断开连接,输入exit即可


