文章目录
- Ubuntu22.04 安装 ssh
- 一、 环境配置
- 二、 启动远程连接
- 三、 开放端口
- 四、 远程连接
 
Ubuntu22.04 安装 ssh
一、 环境配置
安装 Ubuntu 系统后,我们首先需要配置管理员 root 用户:
sudo passwd root
然后,进行软件源的更换:
sudo sed -i "s@http://.*archive.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list
sudo sed -i "s@http://.*security.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list
sudo apt-get update
sudo apt-get upgrade
然后,我们需要安装 openssh-server 服务以及防火墙的服务:
sudo apt-get install openssh-server, ufw
二、 启动远程连接
首先,我们需要修改配置文件:
sudo vim  /etc/ssh/ssh_config

将那行注释取消掉,然后:wq!保存并推出。
最后,启动 ssh 服务:
systemctl status ssh
sudo systemctl start ssh
systemctl status ssh
三、 开放端口
sudo ufw status 
sudo ufw enable 
sudo ufw allow ssh
sudo ufw status 
四、 远程连接
安装完之后,我们就可以使用远程连接工具进行连接了,这里使用的与远程连接工具是 SmarTTY。
-  首先,我们使用 ifconfig获取到我们的 ip 地址 
-  然后,我们使用根据 ip 地址进行连接。  
-  最后,我们成功进入我们的 Linux 系统。 



















