关于Ubuntu静态网络配置以及SSH配置

风中凌乱的猪头 / 2023-05-12 / 原文

1、静态网络配置

  a、查找netplan目录下的默认配置文件,后缀名为.yaml,

  b、ifconfg查看当前网卡以及IP地址(我的是ens33 192.168.138.137)

  c、route -n查看当前网关

  d、windows查看无线网/网络的DNS服务器

  f、进入root模式下,vim /etc/netplan/01-network-manager-all.yaml

  g、执行重启网络命令 netplan apply,ping www.baidu.com是否可以ping通

  修改为以下文件

  

2、ssh配置 (主机安装xshell)

  a、安装ssh sudo apt-get install net-tools

      sudo apt-get install ssh

     sudo apr-get install openssh-server

  b、启动ssh  sudo /etc/init.d/ssh start

        sudo /etc/init.d/ssh stop

        sudo /etc/init.d/ssh restart  (可以用 ps -e |grep ssh查看进程是否运行)

        ifconfig记录ip地址

  c、打开xshell进行连接

3、确认输入密码正确,ssh拒绝密码的问题,如何解决

  修改 /etc/ssh/sshd_config 

  #PermitRootLogin without-password改为PermitRootLogin yes,一定要去掉#号注释才有效

  

  保存退出,重新启动ssh服务 /etc/init.d/ssh restart 则连接成功