22 篇文章带有标签 “networking”

Linux系统网络配置

Ubuntu

修改IP

$ sudo nano /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    eno1:
      addresses:
      - 172.16.33.1/24
      gateway4: 172.16.33.254
      nameservers: {}
  version: 2

应用配置

$ sudo netplan apply
# 推荐使用 debug 参数
$ sudo netplan --debug apply

或者

sudo netplan generate

验证

ip a | grep eno1
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    inet 172.16.33.1/24 brd 172.16.33.255 scope global eno1

参考资料 How to setup a static IP on Ubuntu Server 18.04 How to configure Network Settings in Ubuntu 18.

开启SSH服务

Ubuntu

  • 安装、卸载SSH服务
sudo apt-get install openssh-server
sudo apt-get remove openssh-server
  • 启动、停止、重启SSH服务
sudo service ssh start
sudo service ssh stop
sudo service ssh restart
  • 查询SSH服务状态
service ssh status
  • 配置文件(更改配置需要重启SSH服务)
sudo vi /etc/ssh/sshd_config
  • 连接SSH服务
ssh username@ip -p 22
  • 设置、移除SSH服务开机自启动
sudo update-rc.d ssh defaults
sudo update-rc.d ssh remove
  • 查看SSH服务设置的自启动
ls /etc/rc*
......
......
ls -l /etc/rc2.d/S02ssh
    lrwxrwxrwx 1 root root 13 12月 25 16:33 /etc/rc2.d/S02ssh -> ../init.d/ssh

参考资料