一、下载安装
二、配置
1、换源
- 备份配置文件
$ su #进入root用户
Password: #输入密码
cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
- 下载新的CentOS-Base.repo文件到/etc/yum.repos.d/目录下
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-8-anon.repo
yum clean all #清除原有yum缓存
yum makecache #刷新缓存
2、更新系统
yum clean all
yum check-update #列出清单
yum update
reboot #重启
3、开启SSH
a、安装
yum list installed | grep openssh-server #检查是否安装openssh-server
yum install openssh-server #安装openssh-server
vim /etc/ssh/sshd_config #修改配置
#在打开的文件中去掉下列各项前面的#号
Port 22 #监听端口
ListenAddress 0.0.0.0 #监听地址
ListenAddress ::
PermitRootLog in yes #允许远程登录
PasswordAuthentication yes #用户名、密码验证
service sshd start #开启sshd服务
ps -e | grep sshd #检查是否开启
or
netstat -an | grep 22 #检查是否开启监听
systemctl enable sshd.service #将sshd加入自启动列表
systemctl list-unit-files | grep sshd #检查是否开启自启动
b、查找IP
菜单➫虚拟机➫设置➫网络适配器➫NAT。菜单➫编辑➫虚拟网络编辑器,找到NAT对应的适配器名称为VMnet8。打开CMD,输入ipconfig,找到VMnet8地址为192.168.174.1
> ipconfig
以太网适配器 VMware Network Adapter VMnet8:
连接特定的 DNS 后缀 . . . . . . . :
本地链接 IPv6 地址. . . . . . . . : fe80::60cf:9b52:7f62:7801%6
IPv4 地址 . . . . . . . . . . . . : 192.168.174.1
子网掩码 . . . . . . . . . . . . : 255.255.255.0
默认网关. . . . . . . . . . . . . :
- CentOS终端中输入ifconfig,找到地址为192.168.174.129
ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.174.129 netmask 255.255.255.0 broadcast 192.168.174.255
inet6 fe80::5d74:a093:893:33b3 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:18:2b:13 txqueuelen 1000 (Ethernet)
RX packets 7463 bytes 669015 (653.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 185 bytes 17172 (16.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- 测试能否连通
ping 192.168.174.1 #CentOS终端中输入
ping 192.168.174.129 #CMD中输入
c、CMD使用ssh连接CentOS
> ssh 192.168.174.129 -l user
user@192.168.174.129's password:
[user@localhost ~]$