Locked out of Vagrant box by bad .bashrc. Can I use Vagrantfile to get back in?












1















I have a vagrant box running under the default user vagrant. I access the shell with Putty and a keyfile. I'm on Windows.



I added this command to the end of .bashrc



if [[ ! $TERM =~ screen ]]; then
exec tmux
fi


in an effort to start tmux automatically when I started a session.



But now the shell exits after it loads tmux. I don't get a chance to do anything before it exits.



I've been taking advice on Reddit https://www.reddit.com/r/linuxquestions/comments/ahvdwn/locked_out_of_shell_by_command_in_bashrc_can_i/



So I've tried a lot of things from the logging in side of things but nothing is working.



So my question here is can I use the Vagrantfile to gain access to the box through an alternative configuration? Can I bypass the box's internal setup which is password access turned off, no root access, ssh keyed access for the vagrant user, no ftp (only sftp which uses the secured user).










share|improve this question













migrated from serverfault.com Jan 21 at 14:56


This question came from our site for system and network administrators.























    1















    I have a vagrant box running under the default user vagrant. I access the shell with Putty and a keyfile. I'm on Windows.



    I added this command to the end of .bashrc



    if [[ ! $TERM =~ screen ]]; then
    exec tmux
    fi


    in an effort to start tmux automatically when I started a session.



    But now the shell exits after it loads tmux. I don't get a chance to do anything before it exits.



    I've been taking advice on Reddit https://www.reddit.com/r/linuxquestions/comments/ahvdwn/locked_out_of_shell_by_command_in_bashrc_can_i/



    So I've tried a lot of things from the logging in side of things but nothing is working.



    So my question here is can I use the Vagrantfile to gain access to the box through an alternative configuration? Can I bypass the box's internal setup which is password access turned off, no root access, ssh keyed access for the vagrant user, no ftp (only sftp which uses the secured user).










    share|improve this question













    migrated from serverfault.com Jan 21 at 14:56


    This question came from our site for system and network administrators.





















      1












      1








      1








      I have a vagrant box running under the default user vagrant. I access the shell with Putty and a keyfile. I'm on Windows.



      I added this command to the end of .bashrc



      if [[ ! $TERM =~ screen ]]; then
      exec tmux
      fi


      in an effort to start tmux automatically when I started a session.



      But now the shell exits after it loads tmux. I don't get a chance to do anything before it exits.



      I've been taking advice on Reddit https://www.reddit.com/r/linuxquestions/comments/ahvdwn/locked_out_of_shell_by_command_in_bashrc_can_i/



      So I've tried a lot of things from the logging in side of things but nothing is working.



      So my question here is can I use the Vagrantfile to gain access to the box through an alternative configuration? Can I bypass the box's internal setup which is password access turned off, no root access, ssh keyed access for the vagrant user, no ftp (only sftp which uses the secured user).










      share|improve this question














      I have a vagrant box running under the default user vagrant. I access the shell with Putty and a keyfile. I'm on Windows.



      I added this command to the end of .bashrc



      if [[ ! $TERM =~ screen ]]; then
      exec tmux
      fi


      in an effort to start tmux automatically when I started a session.



      But now the shell exits after it loads tmux. I don't get a chance to do anything before it exits.



      I've been taking advice on Reddit https://www.reddit.com/r/linuxquestions/comments/ahvdwn/locked_out_of_shell_by_command_in_bashrc_can_i/



      So I've tried a lot of things from the logging in side of things but nothing is working.



      So my question here is can I use the Vagrantfile to gain access to the box through an alternative configuration? Can I bypass the box's internal setup which is password access turned off, no root access, ssh keyed access for the vagrant user, no ftp (only sftp which uses the secured user).







      vagrant






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 21 at 1:38









      mos fetishmos fetish

      1061




      1061




      migrated from serverfault.com Jan 21 at 14:56


      This question came from our site for system and network administrators.









      migrated from serverfault.com Jan 21 at 14:56


      This question came from our site for system and network administrators.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Under Linux, the commands below would have granted access :



          vagrant ssh-config > my_ssh_config
          ssh -q -F my_ssh_config vagrant@broken-host '/bin/bash --norc --noprofile'


          On Windows, I suppose that you have to use plink.exe to achieve something similar. Good luck.






          share|improve this answer
























          • As per the advice given on Reddit (link above), attempts of that nature resulted in "open terminal failed: not a terminal" error. In all attempts, ,bashrc loads, loads tmux per the above code, and immediately exits dropping the connection. --norc has zero effect

            – mos fetish
            Jan 21 at 20:01











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fsuperuser.com%2fquestions%2f1396652%2flocked-out-of-vagrant-box-by-bad-bashrc-can-i-use-vagrantfile-to-get-back-in%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Under Linux, the commands below would have granted access :



          vagrant ssh-config > my_ssh_config
          ssh -q -F my_ssh_config vagrant@broken-host '/bin/bash --norc --noprofile'


          On Windows, I suppose that you have to use plink.exe to achieve something similar. Good luck.






          share|improve this answer
























          • As per the advice given on Reddit (link above), attempts of that nature resulted in "open terminal failed: not a terminal" error. In all attempts, ,bashrc loads, loads tmux per the above code, and immediately exits dropping the connection. --norc has zero effect

            – mos fetish
            Jan 21 at 20:01
















          0














          Under Linux, the commands below would have granted access :



          vagrant ssh-config > my_ssh_config
          ssh -q -F my_ssh_config vagrant@broken-host '/bin/bash --norc --noprofile'


          On Windows, I suppose that you have to use plink.exe to achieve something similar. Good luck.






          share|improve this answer
























          • As per the advice given on Reddit (link above), attempts of that nature resulted in "open terminal failed: not a terminal" error. In all attempts, ,bashrc loads, loads tmux per the above code, and immediately exits dropping the connection. --norc has zero effect

            – mos fetish
            Jan 21 at 20:01














          0












          0








          0







          Under Linux, the commands below would have granted access :



          vagrant ssh-config > my_ssh_config
          ssh -q -F my_ssh_config vagrant@broken-host '/bin/bash --norc --noprofile'


          On Windows, I suppose that you have to use plink.exe to achieve something similar. Good luck.






          share|improve this answer













          Under Linux, the commands below would have granted access :



          vagrant ssh-config > my_ssh_config
          ssh -q -F my_ssh_config vagrant@broken-host '/bin/bash --norc --noprofile'


          On Windows, I suppose that you have to use plink.exe to achieve something similar. Good luck.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 21 at 13:04









          Chaoxiang NChaoxiang N

          101




          101













          • As per the advice given on Reddit (link above), attempts of that nature resulted in "open terminal failed: not a terminal" error. In all attempts, ,bashrc loads, loads tmux per the above code, and immediately exits dropping the connection. --norc has zero effect

            – mos fetish
            Jan 21 at 20:01



















          • As per the advice given on Reddit (link above), attempts of that nature resulted in "open terminal failed: not a terminal" error. In all attempts, ,bashrc loads, loads tmux per the above code, and immediately exits dropping the connection. --norc has zero effect

            – mos fetish
            Jan 21 at 20:01

















          As per the advice given on Reddit (link above), attempts of that nature resulted in "open terminal failed: not a terminal" error. In all attempts, ,bashrc loads, loads tmux per the above code, and immediately exits dropping the connection. --norc has zero effect

          – mos fetish
          Jan 21 at 20:01





          As per the advice given on Reddit (link above), attempts of that nature resulted in "open terminal failed: not a terminal" error. In all attempts, ,bashrc loads, loads tmux per the above code, and immediately exits dropping the connection. --norc has zero effect

          – mos fetish
          Jan 21 at 20:01


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • 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%2fsuperuser.com%2fquestions%2f1396652%2flocked-out-of-vagrant-box-by-bad-bashrc-can-i-use-vagrantfile-to-get-back-in%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

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?