ssh_dispatch_run_fatal: Connection to X.X.X.X port 22: DH GEX group out of range

Bugün bir SFTP sitesine dosya yüklemek için komut satırından aşağıdaki komut ile bağlanmaya çalışırken hata aldım:

$sftp tolga@sftp.ftpsite.com
ssh_dispatch_run_fatal: Connection to X.X.X.X port 22: DH GEX group out of range
Connection closed

Hata açıklayıcı olmadığından komutu sftp -vvv tolga@sftp.ftpsite.com ile çalıştırdım (detaylı logu karışıklık olmaması için yazının en sonuna koydum). Aşağıdaki satırlar dikkatimi çekti:

tolga@localhost:~$ sftp -vvv username@sftp.ftpsite.com
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "sftp.ftpsite.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to sftp.ftpsite.com [X.X.X.X] port 22.
debug1: Connection established.
...
...
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug3: send packet: type 34
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug3: receive packet: type 31
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
ssh_dispatch_run_fatal: Connection to X.X.X.X port 22: DH GEX group out of range

Burada bana log’lar iki şey anlatıyordu:

  • sftp.ftpsite.com adresine 22. port’tan ulaşabiliyordum,
  • GEX REQUEST 2048-8192 dışındaydı (out of range).

Biraz araştırınca aslında sorunun kaynağını anlayabildim. İstemci tarafında kullanılan SSH sürümü sunucunun SSH sürümünden yeni olduğunda, istemcinin kullandığı encryption seviyesini sunucu anlamıyor (“out of range” durumu) ve istemci ile bağlantısını kesiyordu.

Oturup biraz daha detaylı araştırma yapınca sorunun SSH Key Exchange (KEX) – Group Exchange (GEX) ile ilgili olduğunu fark ettim. Ben diffie-hellman-group-exchange-sha256 ile bağlantı isteği gönderiyordum, ancak sunucu bu yeni GEX bilgisini anlamayıp “benim kabul sınırım dışında” diyordu.

Bunu düzeltmenin iki yolu var; ya /etc/ssh/ssh_config dosyası içine bir satır ekleyebilirim, ya da bağlantıya özel bir GEX bilgisi tanımlayabilirim. Tabi ki ilk metod tüm SSH bağlantılarının şifrelemesini etkileyeceğinden (şifrelemede daha düşük bir algoritma kullanılacak) bu metod güvenli olan metod değil.

Bunun yerine sadece sftp.ftpsite.com bağlantısına özel bir tanımlama yapmayı seçtim. Bu işlem son derece basit. Temelde ssh yapılandırma dosyası tanımlayarak, ilgili host (sftp.ftpsite.com) için bir istisna oluşturacağız:

1. /home/kullanıcı_adınız/.ssh dizinine geçip config isimli bir dosya oluşturuyoruz:

touch /home/kullanıcı_adınız/.ssh/config

2. Aşağıdaki satırları config dosyası içine yazıyoruz (# ile başlayan ilk satır yorum satırı)

# FTPSITE SFTP Connection option: Tolga-20180321
Host sftp.ftpsite.com
   KexAlgorithms diffie-hellman-group14-sha1

(Dikkatinizi çektiyse diffie-hellman algoritmasını SHA 256’dan SHA1’e indirdik.)

3. SSH servisini yeniden başlatıyoruz:

service ssh restart

Bundan sonra yukarıdaki komut ile bağlanmaya çalıştığımızda  sorunsuz olarak bağlanabileceğiz:

$sftp tolga@sftp.ftpsite.com
Enter password for tolga
Password:

Detaylı olarak baktığımızda ise bağlantı log’larının farkını görebiliyoruz:

debug1: kex: algorithm: diffie-hellman-group14-sha1 
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: sending SSH2_MSG_KEXDH_INIT
debug2: bits set: 1008/2048
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ssh-rsa SHA256: ABC123/DEF456/GHI789
debug3: hostkeys_foreach: reading file "/home/tolga/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/tolga/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from sftp.ftpsite.com
debug3: hostkeys_foreach: reading file "/home/tolga/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/tolga/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys from X.X.X.X
debug1: Host 'sftp.ftpsite.com' is known and matches the RSA host key.
debug1: Found key in /home/tolga/.ssh/known_hosts:1
debug2: bits set: 1045/2048
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug2: key: /home/tolga/.ssh/id_rsa ((nil))
debug2: key: /home/tolga/.ssh/id_dsa ((nil))
debug2: key: /home/tolga/.ssh/id_ecdsa ((nil))
debug2: key: /home/tolga/.ssh/id_ed25519 ((nil))
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
...
...
...
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug3: send packet: type 50
debug2: we sent a keyboard-interactive packet, wait for reply
debug3: receive packet: type 60
debug2: input_userauth_info_req

Şifremizi girerek bağlantımızı sağlıyoruz.

Yazımın başında söylediğim gibi log’ları aşağıya kopyalıyorum (salt metin (txt) olarak yazıma eklemek istedim, ancak WordPress buna izin vermiyor.)

Hatalı bağlantı log’u:

tolga@localhost:~$ sftp -vvv tolga@sftp.ftpsite.com
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving “sftp.ftpsite.com” port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to sftp.ftpsite.com [X.X.X.X] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: Remote protocol version 2.0, remote software version Internet Server SSHD
debug1: no match: Internet Server SSHD
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to sftp.ftpsite.com:22 as ‘tolga’
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256
debug2: host key algorithms: x509v3-sign-rsa,ssh-rsa,x509v3-sign-rsa-sha1
debug2: ciphers ctos: aes128-cbc,3des-ctr,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc,arcfour,arcfour128,arcfour256
debug2: ciphers stoc: aes128-cbc,3des-ctr,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc,arcfour,arcfour128,arcfour256
debug2: MACs ctos: hmac-md5,hmac-sha1,hmac-md5-96,hmac-sha1-96,hmac-sha256,hmac-sha2-256,hmac-sha256@ssh.com
debug2: MACs stoc: hmac-sha256,hmac-md5,hmac-sha1,hmac-md5-96,hmac-sha1-96,hmac-sha2-256,hmac-sha256@ssh.com
debug2: compression ctos: none,zlib
debug2: compression stoc: none,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug3: send packet: type 34
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug3: receive packet: type 31
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
ssh_dispatch_run_fatal: Connection to X.X.X.X port 22: DH GEX group out of range

Başarılı bağlantı log’u:

tolga@localhost:~$ sftp -vvv tolga@sftp.ftpsite.com
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /home/tolga/.ssh/config
debug1: /home/tolga/.ssh/config line 2: Applying options for sftp.ftpsite.com
debug3: kex names ok: [diffie-hellman-group14-sha1]
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving “sftp.ftpsite.com” port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to sftp.ftpsite.com [X.X.X.X] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/tolga/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: Remote protocol version 2.0, remote software version Internet Server SSHD
debug1: no match: Internet Server SSHD
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to sftp.ftpsite.com:22 as ‘tolga’
debug3: hostkeys_foreach: reading file “/home/tolga/.ssh/known_hosts”
debug3: record_hostkey: found key type RSA in file /home/tolga/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from sftp.ftpsite.com
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256
debug2: host key algorithms: x509v3-sign-rsa,ssh-rsa,x509v3-sign-rsa-sha1
debug2: ciphers ctos: aes128-cbc,3des-ctr,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc,arcfour,arcfour128,arcfour256
debug2: ciphers stoc: aes128-cbc,3des-ctr,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc,arcfour,arcfour128,arcfour256
debug2: MACs ctos: hmac-md5,hmac-sha1,hmac-md5-96,hmac-sha1-96,hmac-sha256,hmac-sha2-256,hmac-sha256@ssh.com
debug2: MACs stoc: hmac-sha256,hmac-md5,hmac-sha1,hmac-md5-96,hmac-sha1-96,hmac-sha2-256,hmac-sha256@ssh.com
debug2: compression ctos: none,zlib
debug2: compression stoc: none,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: diffie-hellman-group14-sha1
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: sending SSH2_MSG_KEXDH_INIT
debug2: bits set: 1008/2048
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ssh-rsa SHA256:ABC123/def456/GHI789/jkl012
debug3: hostkeys_foreach: reading file “/home/tolga/.ssh/known_hosts”
debug3: record_hostkey: found key type RSA in file /home/tolga/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from sftp.ftpsite.com
debug3: hostkeys_foreach: reading file “/home/tolga/.ssh/known_hosts”
debug3: record_hostkey: found key type RSA in file /home/tolga/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys from X.X.X.X
debug1: Host ‘sftp.ftpsite.com’ is known and matches the RSA host key.
debug1: Found key in /home/tolga/.ssh/known_hosts:1
debug2: bits set: 1045/2048
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS received
debug2: key: /home/tolga/.ssh/id_rsa ((nil))
debug2: key: /home/tolga/.ssh/id_dsa ((nil))
debug2: key: /home/tolga/.ssh/id_ecdsa ((nil))
debug2: key: /home/tolga/.ssh/id_ed25519 ((nil))
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 53
debug3: input_userauth_banner
This computer system is the private property of ftpsite Corp, ………. LOG OFF IMMEDIATELY if you do not agree.
debug3: receive packet: type 51
debug1: Authentications that can continue: password,publickey,keyboard-interactive
debug3: start over, passed a different list password,publickey,keyboard-interactive
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/tolga/.ssh/id_rsa
debug3: no such identity: /home/tolga/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /home/tolga/.ssh/id_dsa
debug3: no such identity: /home/tolga/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/tolga/.ssh/id_ecdsa
debug3: no such identity: /home/tolga/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/tolga/.ssh/id_ed25519
debug3: no such identity: /home/tolga/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug3: send packet: type 50
debug2: we sent a keyboard-interactive packet, wait for reply
debug3: receive packet: type 60
debug2: input_userauth_info_req
password
Enter password for tolga
debug2: input_userauth_info_req: num_prompts 1
Password:

Sistem

  • Windows 10 Enterprise Version 1703 (OS Build 15063.936)
  • Bash on Ubuntu on Windows

Referanslar:

Reklamlar

Bir Cevap Yazın

Aşağıya bilgilerinizi girin veya oturum açmak için bir simgeye tıklayın:

WordPress.com Logosu

WordPress.com hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap /  Değiştir )

Google+ fotoğrafı

Google+ hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap /  Değiştir )

Twitter resmi

Twitter hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap /  Değiştir )

Facebook fotoğrafı

Facebook hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap /  Değiştir )

Connecting to %s