I am in a cafe. Supposing I ssh into a secure remote server using a key pair, and supposing the cafe wifi is run by a bad actor who is intercepting traffic, can my login be compromised?

I am not talking so much about government-level monitoring - I am talking more about a typical cafe wifi running a compromised router that may be intercepting and recording traffic for analysis by common criminals.


In key pair authentication, we use to authenticate ourself (as we have private key and server has the public key) using access-challenge method.

In this, private key is not sent to server over the network. So, a man-in-the-middle can't get your private key even if he has all the raw packets.


The cryptographic protocols SSH is using are considered secure. The problem is that you cannot be sure with whom you are about to establish a connection. Is it really the server you intend to talk to or is it a man in the middle? In order to be on the safe side you should ask the server administrator for the key fingerprint of the server's public key. The ssh client will show the fingerprint of the key it receives to you for confirmation. If the fingerprints are identical, then you can be sure you are not talking to a man in the middle.


SSH has being proposed to be secure and almost impossible to decrypt (at least for a user-level as the cafe case you're proposing). So most answers would say "no, your login cannot be compromised".

But, recently, as many hackers have been used the SSH tunnels for bad purposes due to its security (as security devices and software may not be able to inspect and/or distinguish malicious or not-malicious ssh traffic); some firms have been developing new products that are able to decrypt and inspect SSH traffic. If, as a theoretical example, a bad actor is running that wifi, using a firewall that lets decrypt and inspect SSH connections, it can be used for a MitM attack (Man-in-the-Middle). Obviously (as @kaidentity remarked and i forgot to tell, thanks) this only would work if the client did not check the server's public key fingerprint.

Readable example: http://blog.checkpoint.com/2015/08/12/ssh-decryption-opens-door-to-very-old-security-vectors/

and: http://code.danyork.com/2015/07/31/firewalls-now-looking-at-intercepting-ssh-traffic-via-a-mitm-attack/

  • @kaneikidev You should add that this only works if the client doesn't check the server's public key finger print... – kaidentity Oct 19 '16 at 11:29
  • @kaidentity you're right, forgot it, let's add it. – KanekiDev Oct 19 '16 at 11:29
  • Thank you for the links. I understand that as long as the initial connection is made on a trusted network, this is not a risk as long as I don't accept any new host fingerprint when connecting on the bad network. – cachvico Oct 19 '16 at 11:30
  • Yes, that's it more or less. – KanekiDev Oct 19 '16 at 11:32
  • What if the client/server authentication is using SSH key pairs? – mootmoot Oct 19 '16 at 15:05

No, if you verified the host key before or from other source (prevents Man in the Middle attack).

Also the private key is not send to the server, which means it can not be intercepted, even if the connection itself would be somehow decrypted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.