Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I try to ssh this in a terminal: ssh I get the following error:
Connection closed by

When I use putty, I am able to connect to the server. Why is this happening, and how can I get this to work in a terminal?

ssh -v

OpenSSH_6.0p1 (CentrifyDC build 5.1.0-472) (CentrifyDC build 5.1.0-472), OpenSSL 0.9.8w 23 Apr 2012
debug1: Reading configuration data /etc/centrifydc/ssh/ssh_config
debug1: /etc/centrifydc/ssh/ssh_config line 52: Applying options for *
debug1: Connecting to [] port 22.
debug1: Connection established.
debug1: identity file /home/ryannaddy/.ssh/id_rsa type -1
debug1: identity file /home/ryannaddy/.ssh/id_rsa-cert type -1
debug1: identity file /home/ryannaddy/.ssh/id_dsa type -1
debug1: identity file /home/ryannaddy/.ssh/id_dsa-cert type -1
debug1: identity file /home/ryannaddy/.ssh/id_ecdsa type -1
debug1: identity file /home/ryannaddy/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5
debug1: match: OpenSSH_5.1p1 Debian-5 pat OpenSSH_5*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.0
debug1: Miscellaneous failure
Cannot resolve network address for KDC in requested realm

debug1: Miscellaneous failure
Cannot resolve network address for KDC in requested realm

debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
Connection closed by
share|improve this question
What does ssh -v show? – James Sneeringer Mar 20 '13 at 13:58
I updated the main question. Also the server should ask for a password, there are no ssh keys required to login. – Get Off My Lawn Mar 20 '13 at 14:10
Did you change any settings from default in PuTTY? – Kruug Mar 20 '13 at 14:15
Also, have you tried Leave out the sub. – Kruug Mar 20 '13 at 14:16
You're using Centrify's build of OpenSSH, which implies your system is AD-integrated. Active Directory uses Kerberos, and OpenSSH is complaining that it can't find the Kerberos KDC, so it's bailing out. What does your /etc/krb5.conf look like? – James Sneeringer Mar 20 '13 at 14:33

Solution found for me via the following URL:

It even does a pretty good job of explaining what is going on.

Ultimately, I added the following to /etc/ssh/ssh_config:

Host *
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
HostKeyAlgorithms ssh-rsa,ssh-dss
MACs hmac-md5,hmac-sha1,hmac-ripemd160

Neither Ciphers, or HostKeyAlgorithms worked on their own, pretty sure MACs put me over the top to get this to work, but I can't be sure, put many hours into getting this solved. I hope this can at least help somebody else.

Edit: This (sometimes) fixes the problem, but probably not in the way you want. --jcwenger

These settings appear to (as a side effect) change the way the ssh client emits packets, and happen to cause it to emit smaller packets. This isn't fixing the problem; it just, sometimes, makes it so that the real problem (MTU fragmentation interacting with stupid firewall rule implementations) isn't triggered.

The correct solution is to set an MTU that works end to end.

Having to manually set MTU to a smaller number to ensure no fragmentation occurs isn't any cleaner (we as users shouldn't have to manually take steps to counter problems caused by our network teams)... but it's at least directly dealing with the actual cause in a reliable and provable way, rather than screwing up SSH's cipher settings in a way that, as a side effect, when the stars align, happens to cause it to not make big packets.

Also, SSH isn't the only thing that makes big packets. Setting MTU keeps the same thing from happening to other protocols too.

share|improve this answer
thanks, in my case just the last line MACs hmac-md5,hmac-sha1,hmac-ripemd160 was enough – Tombart Dec 10 '13 at 22:14
I had a problem with github - git pull / git push - nothing happened. Tried ssh -T -v and got the same error. Used this to solve it. Thank you! – Jason Jan 9 '14 at 23:21
I had a similar problem and tried this solution. One side effect is that any connection to a known host would then accuse a host key change. – lfagundes Feb 28 '14 at 15:18
All of these patches are treating the symptom and not the cause. Reducing cipher size has the potential to prevent MTU fragmentation... which is the real problem, brought up by @jagguli below. – jcwenger Mar 9 '15 at 15:42
Adding the line "HostKeyAlgorithms ssh-rsa,ssh-dss" into /etc/ssh/ssh_config fixed my issue with not being able to SSH into a Zyxel modem. All the other lines in the above tetbox were already in place on my machine. Thank you for the tip! – Jeff Wright Feb 16 at 18:40

This worked for me ...

ifconfig eth0 mtu 576

share|improve this answer

Did some looking and found the following suggestion here:

Try making sure the following line in your /etc/ssh/ssh_config (NOT sshd_config) is NOT commented out:

Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc

You also might try reverting that file back to the default and trying again, i.e. uninstall and reinstall openssh-client IIRC the name of the package.

share|improve this answer
That didn't fix it :( – Get Off My Lawn Mar 20 '13 at 15:04

Change the network interface MTU to solve it. This is a bug for ubuntu 14.04.

This worked for me:

sudo ip li set mtu 1200 dev wlan0


sudo ifconfig wlan0 mtu 1200

ssh fails to connect to VPN host - hangs at 'expecting SSH2_MSG_KEX_ECDH_REPLY'

share|improve this answer

This fixed the MTU issue without having to hardcode some value, it will fix it for ssh and any other protocol effected by this. As root run the following:

echo 2 > /proc/sys/net/ipv4/tcp_mtu_probing

You can read more about the issue and solution here and here.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .