最小化安装Ubutun后的初始化操作

最小化安装Ubutun后的初始化操作

由于Ubutub相关配置路径与红帽系操作系统有些差异,这边进行一些简单初始化记录。

使用的操作系统镜像为:ubuntu-20.04.6-desktop-amd64.iso

1.root账户配置

使用该镜像安装系统,没有红帽系安装过程中对root用户的配置。需要进入系统后使用

sudo passwd root

对root用户进行配置,需要注意的是根据提示第一次输入的密码为当前登录用户的密码。

通过该配置后在系统登录界面还是仅可以通过普通用户登录,无法直接使用root登录系统,使用root需要通过su切换。

2.网络配置

这里是我是通过图形化界面直接配置的,根据官网介绍

https://ubuntu.com/server/docs/network-configuration

可以通过修改/etc/netplan/99_config.yaml进行修改网络配置,这里复制下相关说明。


Static IP address assignment

To configure your system to use static address assignment, create a netplan configuration in the file /etc/netplan/99_config.yaml. The example below assumes you are configuring your first Ethernet interface identified as eth0. Change the addresses, routes, and nameservers values to meet the requirements of your network.

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 10.10.10.2/24
      routes:
        - to: default
          via: 10.10.10.1
      nameservers:
          search: [mydomain, otherdomain]
          addresses: [10.10.10.1, 1.1.1.1]

The configuration can then be applied using the netplan command.

sudo netplan apply

NOTE
netplan in Ubuntu Bionic 18.04 LTS doesn’t understand the “to: default” syntax to specify a default route, and should use the older gateway4: 10.10.10.1 key instead of the whole routes: block.


3.apt源配置

虚拟机装载对应的镜像源

##挂载镜像
mount /dev/sr0 /media
##备份原有源
cd /etc/apt
mv sources.list sources.bak	
##配置本地源,focal为该发行版的标注,不同的镜像该标注不一样,不可通用
cat sources.list
deb file://media focal main

ubuntu本地镜像源似乎没有openssh-server的源包,需要额外配置源,安装openssh-server以使用xshell连接。

root@K8s-master:/etc/apt# apt list |grep ssh

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libssh-4/now 0.9.3-2ubuntu2.2 amd64 [installed,local]
openssh-client/now 1:8.2p1-4ubuntu0.5 amd64 [installed,local]

还是配置下阿里源吧

root@K8s-master:/etc/apt# cat sources.list
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-security multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security universe
deb http://mirrors.aliyun.com/ubuntu/ focal universe
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ focal-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates universe
root@K8s-master:/etc/apt# apt-get update

先安装下vim,自带的vim-tiny无法使用小键盘与上下键,有些不太方便apt install vim -y

4.openssh-server配置

配置完apt源后,就可以安装openssh-server了。

root@K8s-master:/etc/apt# apt install openssh-server -y

在安装一下net-tools以使用常见的网络排查命令,如netstat,过滤22端口,查看服务是否开启。

root@K8s-master:/etc/apt# apt install net-tools
root@K8s-master:/etc/apt# netstat -natp |grep 22
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7422/sshd: /usr/sbi 
tcp6       0      0 :::22                   :::*                    LISTEN      7422/sshd: /usr/sbi 

配置root远程登录

root@K8s-master:/etc/apt# vim /etc/ssh/sshd_config
---
 33 #LoginGraceTime 2m
 34 PermitRootLogin yes
 35 #StrictModes yes
 36 #MaxAuthTries 6
 37 #MaxSessions 10
---
##重启openssh-server服务
root@K8s-master:/etc/apt# systemctl restart sshd

以上配置完成后,即可使用xshell连接配置的Ubuntu系统。

posted @ 2024-04-07 22:29  残-云  阅读(41)  评论(0编辑  收藏  举报