Centos开启SSH服务

在虚拟机(Vmware Workstation)下,安装了CentOS7,现在想通过SSH工具连接虚拟机中的CentOS7

1、 首先,要确保CentOS7安装了 openssh-server,在终端中输入 yum list installed | grep openssh-server

在这里插入图片描述
此处显示已经安装了 openssh-server,如果又没任何输出显示表示没有安装 openssh-server,通过输入 yum install openssh-server

yum list installed | grep openssh-server

来进行安装openssh-server

2、 找到了 /etc/ssh/ 目录下的sshd服务配置文件 sshd_config,用vi编辑器打开

将文件中,关于监听端口、监听地址前的 # 号去除


# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 22
#AddressFamily any
ListenAddress 0.0.0.0
ListenAddress ::

然后开启允许远程登录

# Authentication:

#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

最后,开启使用用户名密码来作为连接验证

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes

保存文件,退出
3、 开启 sshd 服务,输入 sudo service sshd restart

[root@jcgitlabsvr02 bin]# sudo service sshd restart
Redirecting to /bin/systemctl restart sshd.service
   检查  sshd  服务是否已经开启,输入ps -e | grep sshd
[root@jcgitlabsvr02 bin]# ps -e | grep sshd
32642 ?        00:00:00 sshd

参考链接
https://blog.csdn.net/qq_41768362/article/details/117331798

  • 5
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值