I am using an SSH key to connect to my server (I've got Pageant to authenticate my key) and I forgot that I had the VPN on so I connected to the server (SFTP) while I was on it. Should I change my server key or is it ok?

I didn't use any extra software, but the windows VPN option with L2TP.

  • 1
    How is this different from connecting over a standard untrusted network? Did you transfer private keys over this connection without additional encryption?
    – Matthew
    May 27, 2016 at 10:31
  • @Matthew I am not good with network stuff. I didn't transfer anything else other than a couple of php files. Thanks!
    – John
    May 27, 2016 at 10:34

1 Answer 1


You're probably fine. SSH key-based login is designed to work over untrusted networks, without exposing key data - a VPN, even one which you don't control, doesn't change this.

At no point in the sign-in process is the whole private key sent across the network - this would be a massive flaw in the system if it was the case, and would make SSH key login useless over the internet.

In order to steal your key, the VPN provider would need to:

  1. Perform a successful MitM attack on your connection to the server (which would require access to your private key to be successful)


  1. Either inject a command to your system to read your private key, or coerce you into sending it to a remote point once they have a successful MitM in place.

If you were using third party VPN software, there would be a risk of that reading the key directly from your machine, but no more than the risk of any other software you run doing so.

  • Remeber though: if you haven't verified the host key of the remote server through a secure channel, then it would be trivially easy for the VPN to have performed a MITM attack against your first login. So if that was the case then auditing the server's security and/or changing keys may be in order.
    – Perkins
    May 26, 2017 at 22:45

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.