在centos7上ssh服务问题的记录

装了新的centos7系统,发现有些命令改变了,在这里记录下
安装ssh服务
查看是否安装
rpm -qa | grep ssh

[git@VM_78_130_centos ~]$ rpm -qa | grep ssh
openssh-clients-6.4p1-8.el7.x86_64
libssh2-1.4.3-8.el7.x86_64
openssh-6.4p1-8.el7.x86_64
openssh-server-6.4p1-8.el7.x86_64

显示安装了,没有安装的话,输入命令

yum install openssh-server

启动,停止,重新启动

[git@VM_78_130_centos ~]$ service sshd restart
Redirecting to /bin/systemctl restart  sshd.service
Failed to issue method call: Access denied

命令改变了,提示是使用,并且Linux执行成功后,不像之前的有OK输出

systemctl restart  sshd.service

开机启动

sudo chkconfig sshd on
sudo systemctl enable sshd.service

ssh的配置文件在

vim /etc/ssh/sshd_config

基本的设置

要是配置git的话,把下面的三条注释去掉
SAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys

首先先把port改掉默认是22

port 52041

再來是限定登入者

AllowUsers 使用者账号1 使用者账号2 .....

这一行在设定中是没有的,要自己加入

把下面的两行注释去掉
PermitEmptyPasswords no
PasswordAuthentication yes
限制root的用户登录
PermitRootLogin no

开放防火墙

 sudo firewall-cmd --permanent --zone=public --add-port=52041/tcp   

重新读取防火墙

sudo firewall-cmd --reload 

查看端口PORT有沒有加入监控中

netstat -ant
netstat -antp | grep sshd 查看是否启动22端口
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 10.141.78.130:36350     10.53.192.14:9988       ESTABLISHED
tcp        0     28 10.141.78.130:22        113.200.245.36:8377     ESTABLISHED
tcp        0      0 10.141.78.130:22        113.200.245.36:7385     ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值