Cannot login over ssh

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1














I created user accounts on my linux server, then I disabled password logins. I configured ssh to not accept password logins and only accept ssh. I configured the ufw firewall and forgot to allow ssh port. So now I cannot login as no incoming connections are accepted, is there any thing I can do to reset this? The OS running is Ubuntu 14.04 LTS release and it is running inside a VirtualBox vm.










share|improve this question




























    1














    I created user accounts on my linux server, then I disabled password logins. I configured ssh to not accept password logins and only accept ssh. I configured the ufw firewall and forgot to allow ssh port. So now I cannot login as no incoming connections are accepted, is there any thing I can do to reset this? The OS running is Ubuntu 14.04 LTS release and it is running inside a VirtualBox vm.










    share|improve this question


























      1












      1








      1







      I created user accounts on my linux server, then I disabled password logins. I configured ssh to not accept password logins and only accept ssh. I configured the ufw firewall and forgot to allow ssh port. So now I cannot login as no incoming connections are accepted, is there any thing I can do to reset this? The OS running is Ubuntu 14.04 LTS release and it is running inside a VirtualBox vm.










      share|improve this question















      I created user accounts on my linux server, then I disabled password logins. I configured ssh to not accept password logins and only accept ssh. I configured the ufw firewall and forgot to allow ssh port. So now I cannot login as no incoming connections are accepted, is there any thing I can do to reset this? The OS running is Ubuntu 14.04 LTS release and it is running inside a VirtualBox vm.







      sshd ufw






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 20 '18 at 22:23









      Rui F Ribeiro

      39.1k1479130




      39.1k1479130










      asked Aug 31 '15 at 11:21









      Sanik

      83




      83




















          2 Answers
          2






          active

          oldest

          votes


















          1














          Recovery is similar to a lost root password (and might be easiest).



          1. connect to the console of your VM, using virtual box.



          2. a. if you can log from there, log as user, then sudo root, then edit sshd (and firewall rules) and reboot.



            b. if you can't log, neither root/nor user, reboot hosts, upon boot, select kernel (using arrows), edit (using e), then add init=/bin/bash to kernel line.




          3. remount / and /usr, then edit sshd_config



            mount -o remount,rw /
            mount /usr

            vi /etc/ssh/sshd_config
            vi /etc/passwd # see bellow
            vi /fire/wall/rules # (sic)

            reboot


          lost root password ?



          to recover a lost root password, once you are in step 3.



          • passwd root


          • vi /etc/shadow, edit line like root:$6:salt$crypted:... remove $6$... up to but not including : (this will allow login with no password).





          share|improve this answer






















          • Hi archemar, I forgot to mention one more very important thing I am using Vagrant which is using VirtualBox so how can I connect to the console of the VM, because with vagrant I can connect only over ssh. Sorry for framing the question incorrectly
            – Sanik
            Aug 31 '15 at 12:48










          • How do you build you VM ? how do you power it off/on ? How do you add disk/LAN ? in this place you will find the console I told you about.
            – Archemar
            Aug 31 '15 at 13:52










          • Thanks, archemar found the console and followed the steps you provided, problem solved :)
            – Sanik
            Sep 1 '15 at 8:39


















          0














          Try



          $ sudo ufw allow ssh/tcp
          $ sudo ufw logging on
          $ sudo ufw enable
          $ sudo ufw status


          If this does not help go to /etc/hosts.allow add sshd: ALLOW: ALL and restart the sshd, disable the firewall before restarting the sshd






          share|improve this answer






















          • Hi, lucifer I am running Ubuntu 14.04 LTS release through vagrant and because I configured ubuntu to block all incoming connections, I just cannot run the simple command "vagrant ssh" to connect to the linux vm. So I cannot run the commands you mentioned above at all.
            – Sanik
            Aug 31 '15 at 12:50










          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%2f226574%2fcannot-login-over-ssh%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














          Recovery is similar to a lost root password (and might be easiest).



          1. connect to the console of your VM, using virtual box.



          2. a. if you can log from there, log as user, then sudo root, then edit sshd (and firewall rules) and reboot.



            b. if you can't log, neither root/nor user, reboot hosts, upon boot, select kernel (using arrows), edit (using e), then add init=/bin/bash to kernel line.




          3. remount / and /usr, then edit sshd_config



            mount -o remount,rw /
            mount /usr

            vi /etc/ssh/sshd_config
            vi /etc/passwd # see bellow
            vi /fire/wall/rules # (sic)

            reboot


          lost root password ?



          to recover a lost root password, once you are in step 3.



          • passwd root


          • vi /etc/shadow, edit line like root:$6:salt$crypted:... remove $6$... up to but not including : (this will allow login with no password).





          share|improve this answer






















          • Hi archemar, I forgot to mention one more very important thing I am using Vagrant which is using VirtualBox so how can I connect to the console of the VM, because with vagrant I can connect only over ssh. Sorry for framing the question incorrectly
            – Sanik
            Aug 31 '15 at 12:48










          • How do you build you VM ? how do you power it off/on ? How do you add disk/LAN ? in this place you will find the console I told you about.
            – Archemar
            Aug 31 '15 at 13:52










          • Thanks, archemar found the console and followed the steps you provided, problem solved :)
            – Sanik
            Sep 1 '15 at 8:39















          1














          Recovery is similar to a lost root password (and might be easiest).



          1. connect to the console of your VM, using virtual box.



          2. a. if you can log from there, log as user, then sudo root, then edit sshd (and firewall rules) and reboot.



            b. if you can't log, neither root/nor user, reboot hosts, upon boot, select kernel (using arrows), edit (using e), then add init=/bin/bash to kernel line.




          3. remount / and /usr, then edit sshd_config



            mount -o remount,rw /
            mount /usr

            vi /etc/ssh/sshd_config
            vi /etc/passwd # see bellow
            vi /fire/wall/rules # (sic)

            reboot


          lost root password ?



          to recover a lost root password, once you are in step 3.



          • passwd root


          • vi /etc/shadow, edit line like root:$6:salt$crypted:... remove $6$... up to but not including : (this will allow login with no password).





          share|improve this answer






















          • Hi archemar, I forgot to mention one more very important thing I am using Vagrant which is using VirtualBox so how can I connect to the console of the VM, because with vagrant I can connect only over ssh. Sorry for framing the question incorrectly
            – Sanik
            Aug 31 '15 at 12:48










          • How do you build you VM ? how do you power it off/on ? How do you add disk/LAN ? in this place you will find the console I told you about.
            – Archemar
            Aug 31 '15 at 13:52










          • Thanks, archemar found the console and followed the steps you provided, problem solved :)
            – Sanik
            Sep 1 '15 at 8:39













          1












          1








          1






          Recovery is similar to a lost root password (and might be easiest).



          1. connect to the console of your VM, using virtual box.



          2. a. if you can log from there, log as user, then sudo root, then edit sshd (and firewall rules) and reboot.



            b. if you can't log, neither root/nor user, reboot hosts, upon boot, select kernel (using arrows), edit (using e), then add init=/bin/bash to kernel line.




          3. remount / and /usr, then edit sshd_config



            mount -o remount,rw /
            mount /usr

            vi /etc/ssh/sshd_config
            vi /etc/passwd # see bellow
            vi /fire/wall/rules # (sic)

            reboot


          lost root password ?



          to recover a lost root password, once you are in step 3.



          • passwd root


          • vi /etc/shadow, edit line like root:$6:salt$crypted:... remove $6$... up to but not including : (this will allow login with no password).





          share|improve this answer














          Recovery is similar to a lost root password (and might be easiest).



          1. connect to the console of your VM, using virtual box.



          2. a. if you can log from there, log as user, then sudo root, then edit sshd (and firewall rules) and reboot.



            b. if you can't log, neither root/nor user, reboot hosts, upon boot, select kernel (using arrows), edit (using e), then add init=/bin/bash to kernel line.




          3. remount / and /usr, then edit sshd_config



            mount -o remount,rw /
            mount /usr

            vi /etc/ssh/sshd_config
            vi /etc/passwd # see bellow
            vi /fire/wall/rules # (sic)

            reboot


          lost root password ?



          to recover a lost root password, once you are in step 3.



          • passwd root


          • vi /etc/shadow, edit line like root:$6:salt$crypted:... remove $6$... up to but not including : (this will allow login with no password).






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 30 '16 at 22:07









          techraf

          4,153102139




          4,153102139










          answered Aug 31 '15 at 11:42









          Archemar

          19.6k93570




          19.6k93570











          • Hi archemar, I forgot to mention one more very important thing I am using Vagrant which is using VirtualBox so how can I connect to the console of the VM, because with vagrant I can connect only over ssh. Sorry for framing the question incorrectly
            – Sanik
            Aug 31 '15 at 12:48










          • How do you build you VM ? how do you power it off/on ? How do you add disk/LAN ? in this place you will find the console I told you about.
            – Archemar
            Aug 31 '15 at 13:52










          • Thanks, archemar found the console and followed the steps you provided, problem solved :)
            – Sanik
            Sep 1 '15 at 8:39
















          • Hi archemar, I forgot to mention one more very important thing I am using Vagrant which is using VirtualBox so how can I connect to the console of the VM, because with vagrant I can connect only over ssh. Sorry for framing the question incorrectly
            – Sanik
            Aug 31 '15 at 12:48










          • How do you build you VM ? how do you power it off/on ? How do you add disk/LAN ? in this place you will find the console I told you about.
            – Archemar
            Aug 31 '15 at 13:52










          • Thanks, archemar found the console and followed the steps you provided, problem solved :)
            – Sanik
            Sep 1 '15 at 8:39















          Hi archemar, I forgot to mention one more very important thing I am using Vagrant which is using VirtualBox so how can I connect to the console of the VM, because with vagrant I can connect only over ssh. Sorry for framing the question incorrectly
          – Sanik
          Aug 31 '15 at 12:48




          Hi archemar, I forgot to mention one more very important thing I am using Vagrant which is using VirtualBox so how can I connect to the console of the VM, because with vagrant I can connect only over ssh. Sorry for framing the question incorrectly
          – Sanik
          Aug 31 '15 at 12:48












          How do you build you VM ? how do you power it off/on ? How do you add disk/LAN ? in this place you will find the console I told you about.
          – Archemar
          Aug 31 '15 at 13:52




          How do you build you VM ? how do you power it off/on ? How do you add disk/LAN ? in this place you will find the console I told you about.
          – Archemar
          Aug 31 '15 at 13:52












          Thanks, archemar found the console and followed the steps you provided, problem solved :)
          – Sanik
          Sep 1 '15 at 8:39




          Thanks, archemar found the console and followed the steps you provided, problem solved :)
          – Sanik
          Sep 1 '15 at 8:39













          0














          Try



          $ sudo ufw allow ssh/tcp
          $ sudo ufw logging on
          $ sudo ufw enable
          $ sudo ufw status


          If this does not help go to /etc/hosts.allow add sshd: ALLOW: ALL and restart the sshd, disable the firewall before restarting the sshd






          share|improve this answer






















          • Hi, lucifer I am running Ubuntu 14.04 LTS release through vagrant and because I configured ubuntu to block all incoming connections, I just cannot run the simple command "vagrant ssh" to connect to the linux vm. So I cannot run the commands you mentioned above at all.
            – Sanik
            Aug 31 '15 at 12:50















          0














          Try



          $ sudo ufw allow ssh/tcp
          $ sudo ufw logging on
          $ sudo ufw enable
          $ sudo ufw status


          If this does not help go to /etc/hosts.allow add sshd: ALLOW: ALL and restart the sshd, disable the firewall before restarting the sshd






          share|improve this answer






















          • Hi, lucifer I am running Ubuntu 14.04 LTS release through vagrant and because I configured ubuntu to block all incoming connections, I just cannot run the simple command "vagrant ssh" to connect to the linux vm. So I cannot run the commands you mentioned above at all.
            – Sanik
            Aug 31 '15 at 12:50













          0












          0








          0






          Try



          $ sudo ufw allow ssh/tcp
          $ sudo ufw logging on
          $ sudo ufw enable
          $ sudo ufw status


          If this does not help go to /etc/hosts.allow add sshd: ALLOW: ALL and restart the sshd, disable the firewall before restarting the sshd






          share|improve this answer














          Try



          $ sudo ufw allow ssh/tcp
          $ sudo ufw logging on
          $ sudo ufw enable
          $ sudo ufw status


          If this does not help go to /etc/hosts.allow add sshd: ALLOW: ALL and restart the sshd, disable the firewall before restarting the sshd







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 31 '15 at 11:57

























          answered Aug 31 '15 at 11:53









          RockySAnand

          13




          13











          • Hi, lucifer I am running Ubuntu 14.04 LTS release through vagrant and because I configured ubuntu to block all incoming connections, I just cannot run the simple command "vagrant ssh" to connect to the linux vm. So I cannot run the commands you mentioned above at all.
            – Sanik
            Aug 31 '15 at 12:50
















          • Hi, lucifer I am running Ubuntu 14.04 LTS release through vagrant and because I configured ubuntu to block all incoming connections, I just cannot run the simple command "vagrant ssh" to connect to the linux vm. So I cannot run the commands you mentioned above at all.
            – Sanik
            Aug 31 '15 at 12:50















          Hi, lucifer I am running Ubuntu 14.04 LTS release through vagrant and because I configured ubuntu to block all incoming connections, I just cannot run the simple command "vagrant ssh" to connect to the linux vm. So I cannot run the commands you mentioned above at all.
          – Sanik
          Aug 31 '15 at 12:50




          Hi, lucifer I am running Ubuntu 14.04 LTS release through vagrant and because I configured ubuntu to block all incoming connections, I just cannot run the simple command "vagrant ssh" to connect to the linux vm. So I cannot run the commands you mentioned above at all.
          – Sanik
          Aug 31 '15 at 12:50

















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f226574%2fcannot-login-over-ssh%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






          Popular posts from this blog

          Peggy Mitchell

          The Forum (Inglewood, California)

          Palaiologos