在centos7上ssh服务问题的记录

来源:互联网 发布:单片机LED接线 编辑:程序博客网 时间:2024/04/25 07:56

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

[git@VM_78_130_centos ~]$ rpm -qa | grep sshopenssh-clients-6.4p1-8.el7.x86_64libssh2-1.4.3-8.el7.x86_64openssh-6.4p1-8.el7.x86_64openssh-server-6.4p1-8.el7.x86_64

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

yum install openssh-server

启动,停止,重新启动

[git@VM_78_130_centos ~]$ service sshd restartRedirecting to /bin/systemctl restart  sshd.serviceFailed 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 yesPubkeyAuthentication yesAuthorizedKeysFile      .ssh/authorized_keys首先先把port改掉默认是22port 52041再來是限定登入者AllowUsers 使用者账号1 使用者账号2 .....这一行在设定中是没有的,要自己加入把下面的两行注释去掉PermitEmptyPasswords noPasswordAuthentication yes限制root的用户登录PermitRootLogin no

开放防火墙

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

重新读取防火墙

sudo firewall-cmd --reload 

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

netstat -antnetstat -antp | grep sshd 查看是否启动22端口
Active Internet connections (servers and established)Proto Recv-Q Send-Q Local Address           Foreign Address         Statetcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTENtcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTENtcp        0      0 10.141.78.130:36350     10.53.192.14:9988       ESTABLISHEDtcp        0     28 10.141.78.130:22        113.200.245.36:8377     ESTABLISHEDtcp        0      0 10.141.78.130:22        113.200.245.36:7385     ESTABLISHEDtcp6       0      0 :::22                   :::*                    LISTEN
0 0
原创粉丝点击