ubuntu server 18.04的安装 以及配置网络还有ssh服务

时间:2022-11-11 21:20:03

ubuntu server 18.04的安装 以及配置网络还有ssh服务

 

服务器是 dell T420

 

安装过程中规中矩,其中最关键的是分区部分,由于是服务器,如果磁盘比较大的话,一定要用 uefi + gpt

 

其次最好是多分一些区,将home 以及一些目录独立出来 实现程序与数据分离

 

安装完以后需要配置静态的ip 

首先一、查看网络配置状态

 

ifconfig -a
 
二、配置dhcp客户端
修改:/etc/network/interface文件
auto lo
iface lo inet loop back
 
三、配置静态ip
sudo vim /etc/network/interfaces
 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto eno1
iface eno1 inet static
address 10.131.252.160
netmask 255.255.254.0
broadcast 10.131.253.255
gateway 10.131.252.1
dns-nameservers 202.120.224.26

auto eno1
iface eno1 inet6 auto


 
四、配置生效
重启一下网络即可
sudo /etc/init.d/networking restart
 
也可以重启网卡:
sudo ifdown eth0
sudo ifup eht0
如果从远端登录的,执行ifdown eth0则会中断连接的。
ping一下网关,通的话说明没有问题
 
之后便需要安装openssh
首先是apt-get update
不行的话需要更换源
vi /etc/apt/source.list

清华大学源(教育网)

  1.  
    # deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
  2.  
    deb http: //mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted
  3.  
    deb http: //mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted
  4.  
    deb http: //mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe
  5.  
    deb http: //mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe
  6.  
    deb http: //mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse
  7.  
    deb http: //mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse
  8.  
    deb http: //mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
  9.  
    deb http: //mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted
  10.  
    deb http: //mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe
  11.  
    deb http: //mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse

阿里云源

  1.  
    # deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
  2.  
    deb-src http: //archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
  3.  
    deb http: //mirrors.aliyun.com/ubuntu/ xenial main restricted
  4.  
    deb-src http: //mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
  5.  
    deb http: //mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
  6.  
    deb-src http: //mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
  7.  
    deb http: //mirrors.aliyun.com/ubuntu/ xenial universe
  8.  
    deb http: //mirrors.aliyun.com/ubuntu/ xenial-updates universe
  9.  
    deb http: //mirrors.aliyun.com/ubuntu/ xenial multiverse
  10.  
    deb http: //mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
  11.  
    deb http: //mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
  12.  
    deb-src http: //mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
  13.  
    deb http: //archive.canonical.com/ubuntu xenial partner
  14.  
    deb-src http: //archive.canonical.com/ubuntu xenial partner
  15.  
    deb http: //mirrors.aliyun.com/ubuntu/ xenial-security main restricted
  16.  
    deb-src http: //mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
  17.  
    deb http: //mirrors.aliyun.com/ubuntu/ xenial-security universe
  18.  
    deb http: //mirrors.aliyun.com/ubuntu/ xenial-security multiverse
 
之后我们就可以安装了   apt-get install openssh-server
 
打开"终端窗口",输入"sudo ps -e |grep ssh"-->回车-->有sshd,说明ssh服务已经启动,如果没有启动,输入"sudo service ssh start"-->回车-->ssh服务就会启动。
 
打开"终端窗口",输入"sudo gedit /etc/ssh/sshd_config"-->回车-->把配置文件中的"PermitRootLogin without-password"加一个"#"号,把它注释掉-->再增加一句"PermitRootLogin yes"-->保存,修改成功。