Skip to content

ubuntu

常用

  • 快捷键
shell
ctrl + alt + t                # 打开终端
  • 系统相关
shell
# 系统版本
lsb_release -a
cat /etc/os-release

# 修改root密码
sudo passwd root
  • 软件相关
shell
sudo apt install vim

ssh

  • 安装并开启ssh
shell
sudo apt update
sudo apt install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
sudo systemctl status ssh
  • 修改配置文件
shell
# 备份配置文件
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

# 修改配置文件
vi sshd_config                    
PermitRootLogin yes             # 允许root登录
PasswordAuthentication yes       # 启用密码认证

# 重启ssh
sudo systemctl restart ssh

# 测试登录
ssh root@192.168.1.13

防火墙

shell
# 检查防火墙状态
sudo ufw status

# 如果防火墙已启用,允许SSH连接
sudo ufw allow ssh
sudo ufw allow 22/tcp           # 或者指定端口
sudo ufw delete allow 22/tcp    # 删除旧规则

# 查看防火墙规则
sudo ufw status numbered