1 安装参考上一篇:
VMware Workstation 虚拟机安装 ubuntu 24.04 server 详细教程 服务器安装图形化界面-CSDN博客
2 网络配置
#安装
sudo apt install net-tools
#查看
ifconfig
#修改网络配置
sudo vim /etc/netplan/50-cloud-init.yaml
network:
version: 2
ethernets:
ens33:
dhcp4: no
addresses: [192.168.50.19/24]
gateway4: 192.168.50.1
nameservers:
addresses: [192.168.50.1,114.114.114.114]
#启用
sudo netplan apply
#查看
ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:a2:94:12 brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet 192.168.50.19/24 brd 192.168.50.255 scope global ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fea2:9412/64 scope link
valid_lft forever preferred_lft forever
3 ssh 配置
#默认安装之后,Xshell 5 登录直接报错:找不到匹配的host key算法。
vim /etc/ssh/sshd_config
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
#重启ssh服务
sudo systemctl restart ssh
#登录还报错,服务器发送了一个意外的数据包。received:3,expected:20
sudo vi /etc/ssh/sshd_config
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1
#
sudo systemctl restart ssh
再次连接正常,ubuntu ssh 版本高,xshell 用6以上高版本正常
ssh -V
OpenSSH_9.6p1 Ubuntu-3ubuntu13, OpenSSL 3.0.13 30 Jan 2024
4 修改主机名字
sudo hostnamectl set-hostname ubuntuserver
#查看名字
hostname
ubuntuserver
#配置名字和IP关联
sudo vim /etc/hosts
6 增加用户
sudo adduser test
#根据提示,填写信息即可
#增加用户sudo权限
sudo vim /etc/sudoers
test ALL=(ALL:ALL) ALL