MacOS ssh Unable to negotiate with ip port 22: no matching cipher found. Their offer: aes128-cbc

  • 问题还原:在堡垒机连接服务器出现这样的错误
 /Users/liuzhiwei> ssh liuzhiwei01@***ip***
Unable to negotiate with ***ip*** port 22: no matching cipher found. Their offer: aes128-cbc
  • 原因:
    出现错误的原因是要连接的代码仓库服务端的ssh版本过低,客户端与服务端的 cipher 没有匹配上,我们需要在自己的客户端(升级OS后的Mac)重新启用老的 cipher ,这样就能重新建立起连接了。

  • 解决办法 编辑ssh_config文件

➜  /Users/liuzhiwei> sudo vim /etc/ssh/ssh_config 
  • 找到 Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,删除这行前面的#号。
#	$OpenBSD: ssh_config,v 1.34 2019/02/04 02:39:42 dtucker Exp $

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

# Host *
#   ForwardAgent no
#   ForwardX11 no
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
#   Port 22
    Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,[email protected]
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h

Host *
	SendEnv LANG LC_*

  • 保存 ssh_config 这个文件,退出,然后就可以和以前一样通过ssh连接服务器了。

你可能感兴趣的:(Ubuntu,&,Linux)