虚拟机中安装CentOS7

2020-09-07  本文已影响0人  技术永无止境
#备份源:
cd /etc/yum.repos.d
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#下载源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#更新缓存
yum makecache
#清除所有yum缓存
yum clean all
#查看所有的yum源
yum repolist all
#查看可用的yum源
yum repolist enabled
#判断系统是否安装openssh-server
yum list installed | grep openssh-server
#如果没有安装则执行安装
yum install openssh-server
#修改配置
vi /etc/ssh/sshd_config
#打开如下配置:
Port 22
ListenAddress 0.0.0.0
ListenAddress ::
PermitRootLogin yes
PasswordAuthentication yes
#开启ssh服务
sudo service sshd start
#查看服务进程
ps -ef | grep sshd 
netstat -an | grep 22
#添加到自启动
systemctl enable sshd.service
#查看是否开启了自启动
systemctl list-unit-files | grep sshd
上一篇 下一篇

猜你喜欢

热点阅读