Search code examples
sshvpnvpsopensshopenvpn

Is there a way to keep ssh connections alive when ssh host connects to VPN?


I have a remote host ( a VPS ) that I connect to with SSH and it works fine. But sometimes I need to establish VPN connection on it.

By establishing the VPN connection, my ssh breaks and doesn't respond anymore and further tries to connect to it fails with the error:

ssh: connect to host 192.168.1.105 port 22: No route to host

How can I configure VPN or SSH in order to solve this conflict?


Solution

  • As I searched for this problem I saw configurations with iproutes and rules that resolved the problem.But I, myself, found an easy solution by changing the SSH config on client side of tht SSH connection.

    There are some configurations on ssh that is reachable through this link.

    After going through the link I found out you can create or change a config file ( ~/.ssh/conf )

    nano ~/.ssh/conf
    

    And changing it to:

    Host *
       ServerAliveInterval 300
       ServerAliveCountMax 2