记录连接SSH时的一些报错及fedora相关命令

记录连接SSH时的一些报错及fedora相关命令

openSSH卸载与重装

  1. 卸载

先查看openssh的相关包

[root@rainie ~]# rpm -qa openssh*
openssh-server-6.6.1p1-11.el7.x86_64
openssh-6.6.1p1-11.el7.x86_64
openssh-clients-6.6.1p1-11.el7.x86_64

然后依次卸载

[root@rainie ~]# yum remove openssh-server-6.6.1p1-11.el7.x86_64
[root@rainie ~]# yum remove openssh-clients-6.6.1p1-11.el7.x86_64
[root@rainie ~]# yum remove openssh-6.6.1p1-11.el7.x86_64
  1. 安装

    [root@rainie ~]# yum install -y openssh-server-6.6.1p1-11.el7.x86_64
    [root@rainie ~]# yum install -y openssh-clients-6.6.1p1-11.el7.x86_64

  2. 然后重新启动ssh服务

[root@rainie ~]# service sshd start

sshd服务的状态、重启、启动命令

systemctl status sshd.service
systemctl restart sshd.service
systemctl start sshd.service

sudo service sshd status
sudo service sshd restart
sudo service sshd start

关闭防火墙

systemctl stop firewalld

永久关闭防火墙

禁止开机启动

systemctl disable firewalld

进入root权限模式(有些命令需要在root权限下进行操作)

# su
password:(输入密码)

赋予文件或文件夹权限

chmod 777 /etc/ssh/sshd_config

报错信息:

Server responded "algorithm negotiation failed” .
Key exchange with the remote host failed.This can happen for example if the remote host computer does not support the selected algorithms.

解决方案:

修改ssh的配置文件 vi /etc/ssh/sshd_config

在配置文件中添加:

Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc
MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org

然而我添加之后重启不了ssh服务,通过命令查看报错信息

# /usr/sbin/sshd -T

会提示哪一行有错误,下面是某一行的报错提示

failed with result ‘exit-code’

也就是我刚刚在配置文件中加进去的那一段,去掉之后则可以重启成功,所以正在寻找前个问题的另一种解决方法…

这里可能还会用到一个命令就是查看SeLinux设置的ssh端口,与配置文件里的端口号进行对比看是否已匹配

# semanage port -l | grep ssh

  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值