Starting SSH server after VPN starts Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionSSH Server on Ubuntu not worksHow does OpenVPN server assign client IP addresses in case of multiclient configuration?ssh into a server which is connected to a VPN serviceConnect to Ubuntu Server through SSH over the internetPort forwarding to two different VPN clients on the same serverSSH server also runs OpenVPN client - Inbound SSH times outAllow SSH connection not using my VPNAble to ssh into OpenVPN server after establishing VPN tunnel, but unable to connect to other machines on my server side LAN or on the InternetCannot create OpenSSH tunnelAccess LAN computers via VPN connection

Apollo command module space walk?

Identifying polygons that intersect with another layer using QGIS?

List *all* the tuples!

Output the ŋarâþ crîþ alphabet song without using (m)any letters

Fundamental Solution of the Pell Equation

When do you get frequent flier miles - when you buy, or when you fly?

Why did the rest of the Eastern Bloc not invade Yugoslavia?

How can I make names more distinctive without making them longer?

At the end of Thor: Ragnarok why don't the Asgardians turn and head for the Bifrost as per their original plan?

2001: A Space Odyssey's use of the song "Daisy Bell" (Bicycle Built for Two); life imitates art or vice-versa?

How would the world control an invulnerable immortal mass murderer?

How does the particle を relate to the verb 行く in the structure「A を + B に行く」?

How do I stop a creek from eroding my steep embankment?

Check which numbers satisfy the condition [A*B*C = A! + B! + C!]

Why is my conclusion inconsistent with the van't Hoff equation?

How to tell that you are a giant?

Is there a program I can run on the C64 to speed up booting of a game?

What is the meaning of the new sigil in Game of Thrones Season 8 intro?

Can a non-EU citizen traveling with me come with me through the EU passport line?

Do I really need recursive chmod to restrict access to a folder?

Storing hydrofluoric acid before the invention of plastics

How to react to hostile behavior from a senior developer?

Is the Standard Deduction better than Itemized when both are the same amount?

How to align text above triangle figure



Starting SSH server after VPN starts



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionSSH Server on Ubuntu not worksHow does OpenVPN server assign client IP addresses in case of multiclient configuration?ssh into a server which is connected to a VPN serviceConnect to Ubuntu Server through SSH over the internetPort forwarding to two different VPN clients on the same serverSSH server also runs OpenVPN client - Inbound SSH times outAllow SSH connection not using my VPNAble to ssh into OpenVPN server after establishing VPN tunnel, but unable to connect to other machines on my server side LAN or on the InternetCannot create OpenSSH tunnelAccess LAN computers via VPN connection



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















I am running an OpenVPN server on Ubuntu 14.04 as well as OpenSSH.



I have my SSH server configured to bind to an IP address on my VPN interface. Once my machine boots, binding to that IP fails.



Once I log in, can see with netstat that sshd is not listening. I am able to restart sshd and the machine will start listening properly. The IP on my VPN is the only IP I have configured sshd to listen on.



At Boot:



sshd[1016]: Set /proc/self/oom_score_adj from 0 to -1000
sshd[1016]: error: Bind to port 22 on 10.8.0.1 failed: Cannot assign requested address.
sshd[1016]: fatal: Cannot bind any address.


Restart SSH:



sshd[3481]: Set /proc/self/oom_score_adj from 0 to -1000
sshd[3481]: Server listening on 10.8.0.1 port 22.


My best guess is that sshd is starting before my VPN is up and running. Is there a way I am able to ensure sshd starts afterwards so it can bind properly?



Any suggestions about what to do or check?










share|improve this question
























  • There most likely is, but it will largely depend on your OS/distro. Please edit your question w/ that piece of information.

    – tink
    Jul 17 '14 at 4:08











  • I have included it. It is on the first line. I am running Ubuntu 14.04.

    – ehaydenr
    Jul 17 '14 at 4:09

















4















I am running an OpenVPN server on Ubuntu 14.04 as well as OpenSSH.



I have my SSH server configured to bind to an IP address on my VPN interface. Once my machine boots, binding to that IP fails.



Once I log in, can see with netstat that sshd is not listening. I am able to restart sshd and the machine will start listening properly. The IP on my VPN is the only IP I have configured sshd to listen on.



At Boot:



sshd[1016]: Set /proc/self/oom_score_adj from 0 to -1000
sshd[1016]: error: Bind to port 22 on 10.8.0.1 failed: Cannot assign requested address.
sshd[1016]: fatal: Cannot bind any address.


Restart SSH:



sshd[3481]: Set /proc/self/oom_score_adj from 0 to -1000
sshd[3481]: Server listening on 10.8.0.1 port 22.


My best guess is that sshd is starting before my VPN is up and running. Is there a way I am able to ensure sshd starts afterwards so it can bind properly?



Any suggestions about what to do or check?










share|improve this question
























  • There most likely is, but it will largely depend on your OS/distro. Please edit your question w/ that piece of information.

    – tink
    Jul 17 '14 at 4:08











  • I have included it. It is on the first line. I am running Ubuntu 14.04.

    – ehaydenr
    Jul 17 '14 at 4:09













4












4








4


1






I am running an OpenVPN server on Ubuntu 14.04 as well as OpenSSH.



I have my SSH server configured to bind to an IP address on my VPN interface. Once my machine boots, binding to that IP fails.



Once I log in, can see with netstat that sshd is not listening. I am able to restart sshd and the machine will start listening properly. The IP on my VPN is the only IP I have configured sshd to listen on.



At Boot:



sshd[1016]: Set /proc/self/oom_score_adj from 0 to -1000
sshd[1016]: error: Bind to port 22 on 10.8.0.1 failed: Cannot assign requested address.
sshd[1016]: fatal: Cannot bind any address.


Restart SSH:



sshd[3481]: Set /proc/self/oom_score_adj from 0 to -1000
sshd[3481]: Server listening on 10.8.0.1 port 22.


My best guess is that sshd is starting before my VPN is up and running. Is there a way I am able to ensure sshd starts afterwards so it can bind properly?



Any suggestions about what to do or check?










share|improve this question
















I am running an OpenVPN server on Ubuntu 14.04 as well as OpenSSH.



I have my SSH server configured to bind to an IP address on my VPN interface. Once my machine boots, binding to that IP fails.



Once I log in, can see with netstat that sshd is not listening. I am able to restart sshd and the machine will start listening properly. The IP on my VPN is the only IP I have configured sshd to listen on.



At Boot:



sshd[1016]: Set /proc/self/oom_score_adj from 0 to -1000
sshd[1016]: error: Bind to port 22 on 10.8.0.1 failed: Cannot assign requested address.
sshd[1016]: fatal: Cannot bind any address.


Restart SSH:



sshd[3481]: Set /proc/self/oom_score_adj from 0 to -1000
sshd[3481]: Server listening on 10.8.0.1 port 22.


My best guess is that sshd is starting before my VPN is up and running. Is there a way I am able to ensure sshd starts afterwards so it can bind properly?



Any suggestions about what to do or check?







vpn openvpn openssh sshd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 17 '14 at 12:50









Patrick

51.6k11134183




51.6k11134183










asked Jul 17 '14 at 3:17









ehaydenrehaydenr

3115




3115












  • There most likely is, but it will largely depend on your OS/distro. Please edit your question w/ that piece of information.

    – tink
    Jul 17 '14 at 4:08











  • I have included it. It is on the first line. I am running Ubuntu 14.04.

    – ehaydenr
    Jul 17 '14 at 4:09

















  • There most likely is, but it will largely depend on your OS/distro. Please edit your question w/ that piece of information.

    – tink
    Jul 17 '14 at 4:08











  • I have included it. It is on the first line. I am running Ubuntu 14.04.

    – ehaydenr
    Jul 17 '14 at 4:09
















There most likely is, but it will largely depend on your OS/distro. Please edit your question w/ that piece of information.

– tink
Jul 17 '14 at 4:08





There most likely is, but it will largely depend on your OS/distro. Please edit your question w/ that piece of information.

– tink
Jul 17 '14 at 4:08













I have included it. It is on the first line. I am running Ubuntu 14.04.

– ehaydenr
Jul 17 '14 at 4:09





I have included it. It is on the first line. I am running Ubuntu 14.04.

– ehaydenr
Jul 17 '14 at 4:09










2 Answers
2






active

oldest

votes


















1














I found a solution.



In the OpenVPN configuration file /etc/openvpn/server.conf you can specify a script to run on up. If you take a look at the OpenVPN manual page man openvpn, you will see --up cmd. In the /etc/openvpn/server.conf configuration file, I added a line:



up "/etc/openvpn/up.sh"


This file is one that I created and will be executed when the VPN starts. Right now, mine looks like this:



#!/bin/sh
logger VPN is UP
service ssh restart


Now, every time my OpenVPN server starts up, it will also restart the OpenSSH server as well. Likewise, I am able to also use --down cmd and specify a file in the server configuration file if I wish to have a script executed when the server is shutdown.



You can read more about these in the OpenVPN manual page - man openvpn






share|improve this answer

























  • How did you set up SSH to bind to the VPN interface?

    – JB0x2D1
    Oct 2 '14 at 17:21











  • @JB0x2D1 I achieved it without actually binding the interface. I bound it to the IP address i knew my machine would be on after connecting to the VPN. In this case, I was hosting the VPN so I knew what ip my machine (The VPN server) would have inside the VPN. From there, you just have ssh only listen on that ip address. I am not sure whether this is 100% reliable. It was for me, but i would imagine interface binding would be better. Please comment if you learn how to bind.

    – ehaydenr
    Oct 2 '14 at 18:05











  • Thanks. I think the problem is with my client. I can connect to the VPN then run SSH with no problems on one client but not with another. The problem client is running Lubuntu

    – JB0x2D1
    Oct 2 '14 at 18:10


















0














Looks like ssh uses upstart, but openvpn doesn't ... you might be able to force ssh to come up delayed by doing this, but it's untested (I don't want to mess up my install):



update-rc.d ssh defaults 99


And as it's untested: CAVEAT EMPTOR






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f144992%2fstarting-ssh-server-after-vpn-starts%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I found a solution.



    In the OpenVPN configuration file /etc/openvpn/server.conf you can specify a script to run on up. If you take a look at the OpenVPN manual page man openvpn, you will see --up cmd. In the /etc/openvpn/server.conf configuration file, I added a line:



    up "/etc/openvpn/up.sh"


    This file is one that I created and will be executed when the VPN starts. Right now, mine looks like this:



    #!/bin/sh
    logger VPN is UP
    service ssh restart


    Now, every time my OpenVPN server starts up, it will also restart the OpenSSH server as well. Likewise, I am able to also use --down cmd and specify a file in the server configuration file if I wish to have a script executed when the server is shutdown.



    You can read more about these in the OpenVPN manual page - man openvpn






    share|improve this answer

























    • How did you set up SSH to bind to the VPN interface?

      – JB0x2D1
      Oct 2 '14 at 17:21











    • @JB0x2D1 I achieved it without actually binding the interface. I bound it to the IP address i knew my machine would be on after connecting to the VPN. In this case, I was hosting the VPN so I knew what ip my machine (The VPN server) would have inside the VPN. From there, you just have ssh only listen on that ip address. I am not sure whether this is 100% reliable. It was for me, but i would imagine interface binding would be better. Please comment if you learn how to bind.

      – ehaydenr
      Oct 2 '14 at 18:05











    • Thanks. I think the problem is with my client. I can connect to the VPN then run SSH with no problems on one client but not with another. The problem client is running Lubuntu

      – JB0x2D1
      Oct 2 '14 at 18:10















    1














    I found a solution.



    In the OpenVPN configuration file /etc/openvpn/server.conf you can specify a script to run on up. If you take a look at the OpenVPN manual page man openvpn, you will see --up cmd. In the /etc/openvpn/server.conf configuration file, I added a line:



    up "/etc/openvpn/up.sh"


    This file is one that I created and will be executed when the VPN starts. Right now, mine looks like this:



    #!/bin/sh
    logger VPN is UP
    service ssh restart


    Now, every time my OpenVPN server starts up, it will also restart the OpenSSH server as well. Likewise, I am able to also use --down cmd and specify a file in the server configuration file if I wish to have a script executed when the server is shutdown.



    You can read more about these in the OpenVPN manual page - man openvpn






    share|improve this answer

























    • How did you set up SSH to bind to the VPN interface?

      – JB0x2D1
      Oct 2 '14 at 17:21











    • @JB0x2D1 I achieved it without actually binding the interface. I bound it to the IP address i knew my machine would be on after connecting to the VPN. In this case, I was hosting the VPN so I knew what ip my machine (The VPN server) would have inside the VPN. From there, you just have ssh only listen on that ip address. I am not sure whether this is 100% reliable. It was for me, but i would imagine interface binding would be better. Please comment if you learn how to bind.

      – ehaydenr
      Oct 2 '14 at 18:05











    • Thanks. I think the problem is with my client. I can connect to the VPN then run SSH with no problems on one client but not with another. The problem client is running Lubuntu

      – JB0x2D1
      Oct 2 '14 at 18:10













    1












    1








    1







    I found a solution.



    In the OpenVPN configuration file /etc/openvpn/server.conf you can specify a script to run on up. If you take a look at the OpenVPN manual page man openvpn, you will see --up cmd. In the /etc/openvpn/server.conf configuration file, I added a line:



    up "/etc/openvpn/up.sh"


    This file is one that I created and will be executed when the VPN starts. Right now, mine looks like this:



    #!/bin/sh
    logger VPN is UP
    service ssh restart


    Now, every time my OpenVPN server starts up, it will also restart the OpenSSH server as well. Likewise, I am able to also use --down cmd and specify a file in the server configuration file if I wish to have a script executed when the server is shutdown.



    You can read more about these in the OpenVPN manual page - man openvpn






    share|improve this answer















    I found a solution.



    In the OpenVPN configuration file /etc/openvpn/server.conf you can specify a script to run on up. If you take a look at the OpenVPN manual page man openvpn, you will see --up cmd. In the /etc/openvpn/server.conf configuration file, I added a line:



    up "/etc/openvpn/up.sh"


    This file is one that I created and will be executed when the VPN starts. Right now, mine looks like this:



    #!/bin/sh
    logger VPN is UP
    service ssh restart


    Now, every time my OpenVPN server starts up, it will also restart the OpenSSH server as well. Likewise, I am able to also use --down cmd and specify a file in the server configuration file if I wish to have a script executed when the server is shutdown.



    You can read more about these in the OpenVPN manual page - man openvpn







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 9 hours ago









    Rui F Ribeiro

    42.1k1484142




    42.1k1484142










    answered Jul 18 '14 at 3:26









    ehaydenrehaydenr

    3115




    3115












    • How did you set up SSH to bind to the VPN interface?

      – JB0x2D1
      Oct 2 '14 at 17:21











    • @JB0x2D1 I achieved it without actually binding the interface. I bound it to the IP address i knew my machine would be on after connecting to the VPN. In this case, I was hosting the VPN so I knew what ip my machine (The VPN server) would have inside the VPN. From there, you just have ssh only listen on that ip address. I am not sure whether this is 100% reliable. It was for me, but i would imagine interface binding would be better. Please comment if you learn how to bind.

      – ehaydenr
      Oct 2 '14 at 18:05











    • Thanks. I think the problem is with my client. I can connect to the VPN then run SSH with no problems on one client but not with another. The problem client is running Lubuntu

      – JB0x2D1
      Oct 2 '14 at 18:10

















    • How did you set up SSH to bind to the VPN interface?

      – JB0x2D1
      Oct 2 '14 at 17:21











    • @JB0x2D1 I achieved it without actually binding the interface. I bound it to the IP address i knew my machine would be on after connecting to the VPN. In this case, I was hosting the VPN so I knew what ip my machine (The VPN server) would have inside the VPN. From there, you just have ssh only listen on that ip address. I am not sure whether this is 100% reliable. It was for me, but i would imagine interface binding would be better. Please comment if you learn how to bind.

      – ehaydenr
      Oct 2 '14 at 18:05











    • Thanks. I think the problem is with my client. I can connect to the VPN then run SSH with no problems on one client but not with another. The problem client is running Lubuntu

      – JB0x2D1
      Oct 2 '14 at 18:10
















    How did you set up SSH to bind to the VPN interface?

    – JB0x2D1
    Oct 2 '14 at 17:21





    How did you set up SSH to bind to the VPN interface?

    – JB0x2D1
    Oct 2 '14 at 17:21













    @JB0x2D1 I achieved it without actually binding the interface. I bound it to the IP address i knew my machine would be on after connecting to the VPN. In this case, I was hosting the VPN so I knew what ip my machine (The VPN server) would have inside the VPN. From there, you just have ssh only listen on that ip address. I am not sure whether this is 100% reliable. It was for me, but i would imagine interface binding would be better. Please comment if you learn how to bind.

    – ehaydenr
    Oct 2 '14 at 18:05





    @JB0x2D1 I achieved it without actually binding the interface. I bound it to the IP address i knew my machine would be on after connecting to the VPN. In this case, I was hosting the VPN so I knew what ip my machine (The VPN server) would have inside the VPN. From there, you just have ssh only listen on that ip address. I am not sure whether this is 100% reliable. It was for me, but i would imagine interface binding would be better. Please comment if you learn how to bind.

    – ehaydenr
    Oct 2 '14 at 18:05













    Thanks. I think the problem is with my client. I can connect to the VPN then run SSH with no problems on one client but not with another. The problem client is running Lubuntu

    – JB0x2D1
    Oct 2 '14 at 18:10





    Thanks. I think the problem is with my client. I can connect to the VPN then run SSH with no problems on one client but not with another. The problem client is running Lubuntu

    – JB0x2D1
    Oct 2 '14 at 18:10













    0














    Looks like ssh uses upstart, but openvpn doesn't ... you might be able to force ssh to come up delayed by doing this, but it's untested (I don't want to mess up my install):



    update-rc.d ssh defaults 99


    And as it's untested: CAVEAT EMPTOR






    share|improve this answer



























      0














      Looks like ssh uses upstart, but openvpn doesn't ... you might be able to force ssh to come up delayed by doing this, but it's untested (I don't want to mess up my install):



      update-rc.d ssh defaults 99


      And as it's untested: CAVEAT EMPTOR






      share|improve this answer

























        0












        0








        0







        Looks like ssh uses upstart, but openvpn doesn't ... you might be able to force ssh to come up delayed by doing this, but it's untested (I don't want to mess up my install):



        update-rc.d ssh defaults 99


        And as it's untested: CAVEAT EMPTOR






        share|improve this answer













        Looks like ssh uses upstart, but openvpn doesn't ... you might be able to force ssh to come up delayed by doing this, but it's untested (I don't want to mess up my install):



        update-rc.d ssh defaults 99


        And as it's untested: CAVEAT EMPTOR







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 17 '14 at 4:20









        tinktink

        4,50711222




        4,50711222



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f144992%2fstarting-ssh-server-after-vpn-starts%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            -openssh, openvpn, sshd, vpn

            Popular posts from this blog

            Creating 100m^2 grid automatically using QGIS?Creating grid constrained within polygon in QGIS?Createing polygon layer from point data using QGIS?Creating vector grid using QGIS?Creating grid polygons from coordinates using R or PythonCreating grid from spatio temporal point data?Creating fields in attributes table using other layers using QGISCreate .shp vector grid in QGISQGIS Creating 4km point grid within polygonsCreate a vector grid over a raster layerVector Grid Creates just one grid

            What is this called? Old film camera viewer?What makes a good film camera?What to do with an old film camera?What should one look for when buying a used film camera?What is the value and age of this pre-1967 Ricoh 35 mm camera?DSLR recommendation, question about old Canon 35mm film Camera & lensesCan anyone identify the silver rangefinder-style camera in this advertisement?What kind of a Polaroid 600-camera is this?Will an old film camera still work even when not used in a very long time?What is this camera / Can I develop the film?How to fit an action camera into antique (bellows) housing?What to check when buying used and old film bodies?

            Why is this plane circling around the Lucknow airport every day?Why do aircraft on Flight Radar 24 jump around randomly sometimes?What airport has this walkway over a taxiway?How does Chicago O'Hare's tower sequence aircraft at peak capacity?Which airport is featured in this Delta commercial?After a crash, for how long is the airport closed?Can a passenger plane stand still in the air, or hover at a fixed location above a ground?What are those trucks towing around, and why?What is this airport outside of Cairo, Egypt?Which US airport has the lowest circling MDH?What is this airport video?