Ubuntu虚拟机装机流程

这两天尝试安装了一下linux虚拟机,考虑到以后可能还会用到,在这里做一个记录。

创建虚拟机

使用VMWare创建虚拟机,选择linux发行版,目前选择版本(ubuntu-20.04.4-live-server-amd64.iso),注意:Ubuntu的Desktop版本是带UI界面的,通常只需要安装Server版本即可,注意勾选安装ssh服务
设置root初始密码

等待系统安装完毕后,使用普通用户登录系统,通过 sudo passwd root 命令设置root初始密码
配置ssh服务

配置文件:/etc/ssh/sshd_config
    1、配置sshd服务端口号,找到 #port 22所在行,将前面的#去掉
    2、设置允许root用户远程登录,找到 #PermitRootLogin prohibit-password那行,将其修改为 PermitRootLogin yes
    3、重载或者重启sshd服务:systemctl reload sshd 或 systemctl restart sshd    
安装net-tools

apt install net-tools
Xftp远程登录

使用ifconfig -a 命令查看IP信息,然后使用Xftp远程登录
    遇到问题:服务器发送了一个意外的数据包。received: 3, expected: 20
    有两种解决方法:
    1、升级xftp至xftp6;
    2、在/etc/ssh/sshd_config最后增加如下信息

KexAlgorithms [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

        然后重载或重启sshd服务:systemctl reload sshd 或 systemctl restart sshd
改用阿里云镜像

使用root用户远程登录,替换sources.list,位于/etc/apt位置,更新和升级apt缓存:sudo apt-get update 与 sudo apt-get upgrade
防火墙配置

Ubuntu防火墙一般使用ufw,如果开启的话,有几个端口记得放开,用于ssh连接的22和数据库的3306端口:

ufw allow 22/tcp
ufw allow 3306/tcp

设置时区

可使用 date 或者 timedatectl 命令来查看当前系统的时区

使用 tzselect命令进行时区选择,该命令会引导用户选择地理区域、国家和城市,并输出相应的时区信息。

根据上一步的输出结果,使用 timedatectl set-timezone命令设置系统时区。例如,下面命令将时区设置为中国上海

timedatectl set-timezone Asia/Shanghai

你可能感兴趣的:(Linux,Ubuntu,虚拟机)