Unable to login to ec2 instance after running “sudo chmod 2770 /”Changed AWS EC2 firewall rule and locked...

Would life expectancy increase if we replaced healthy organs with artificial ones?

Unions, aliasing and type-punning in practice: what works and what does not?

Why is it a problem for Freddie if the guys from Munich did what he wanted?

Ethernet cable only works in certain positions

Are all aperiodic systems chaotic?

How does a single engine tail wheel landing gear airplane turn when it is on the ground?

Why don't hotels offer ≥ 1 kitchen that must be booked?

US ESTA Question confusion

Is it illegal to infringe copyright if your boss or your client ordered you to do it?

Why did Shae (falsely) implicate Sansa?

Why are recumbent bicycles and velomobiles illegal in UCI bicycle racing?

Lost citations on Scholar

Drawing a function without knowing its definition

Can you recognize a low private exponent from a public key?

How bad is a Computer Science course that doesn't teach Design Patterns?

How to convince HR to let my star employee work from home?

Can "so" express a reason not a result?

What prevents people from lying about where they live in order to reduce state income taxes?

What happens when the last remaining players refuse to kill each other?

How to make clear what a part-humanoid character looks like when they're quite common in their world?

Headless horseman claims new head

Taking an academic pseudonym?

Is there a limit on the layers of encryption a file can have?

"Cheaper by the dozen" phrase origin?



Unable to login to ec2 instance after running “sudo chmod 2770 /”


Changed AWS EC2 firewall rule and locked out of sshWhy do I get permission denied every time I try to ssh from an amazon ec2 server to another linux host?SSH doesn't ask for password, gives “permission denied” immediatelyec2 instance is unable to connect after restartCan't SSH Into EC2 InstanceEC2 instance always ask me to enter passphrase for the pem during connectionUnable to connect EC2 instance via sshwhy rsync is not working with crontab?Cannot SSH to my AWS Linux instance after rebooting itAWS EC2: Can't log into instanceUnable to ping the remote user via ansible













3















I am new to linux and AWS.



I ran sudo chmod 2770 / command on my ec2 instance and after that




I was getting Permission denied on everything I was doing(even using
ls or cd)




So I exited my connection(using cygwin) and tried to re-connect but now I get




Permission denied (publickey,gssapi-keyex,gssapi-with-mic)




I tried setting chmod 400 my.pem , chmod 600 my.pem, chmod 777 my.pem but nothing worked.

I am trying to connect using ssh -i my.pem ec2-user@xx.xx.xx.x which was working fine earlier.

What is the solution?










share|improve this question







New contributor




iAmLearning is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • I have installed so many things on my instance. I don't want to loose it. Is there any way to get it back ?

    – iAmLearning
    6 hours ago






  • 3





    You should be using EBS snapshots to ensure you can recover your instance to a point in time that it's working. The advice from MLu below is what I'd have said too. Don't experiment on servers that have important data. I did something similar on my EC2 instance when I was learning, I had to restore to a snapshot because it was far too difficult to fix.

    – Tim
    5 hours ago
















3















I am new to linux and AWS.



I ran sudo chmod 2770 / command on my ec2 instance and after that




I was getting Permission denied on everything I was doing(even using
ls or cd)




So I exited my connection(using cygwin) and tried to re-connect but now I get




Permission denied (publickey,gssapi-keyex,gssapi-with-mic)




I tried setting chmod 400 my.pem , chmod 600 my.pem, chmod 777 my.pem but nothing worked.

I am trying to connect using ssh -i my.pem ec2-user@xx.xx.xx.x which was working fine earlier.

What is the solution?










share|improve this question







New contributor




iAmLearning is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • I have installed so many things on my instance. I don't want to loose it. Is there any way to get it back ?

    – iAmLearning
    6 hours ago






  • 3





    You should be using EBS snapshots to ensure you can recover your instance to a point in time that it's working. The advice from MLu below is what I'd have said too. Don't experiment on servers that have important data. I did something similar on my EC2 instance when I was learning, I had to restore to a snapshot because it was far too difficult to fix.

    – Tim
    5 hours ago














3












3








3








I am new to linux and AWS.



I ran sudo chmod 2770 / command on my ec2 instance and after that




I was getting Permission denied on everything I was doing(even using
ls or cd)




So I exited my connection(using cygwin) and tried to re-connect but now I get




Permission denied (publickey,gssapi-keyex,gssapi-with-mic)




I tried setting chmod 400 my.pem , chmod 600 my.pem, chmod 777 my.pem but nothing worked.

I am trying to connect using ssh -i my.pem ec2-user@xx.xx.xx.x which was working fine earlier.

What is the solution?










share|improve this question







New contributor




iAmLearning is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I am new to linux and AWS.



I ran sudo chmod 2770 / command on my ec2 instance and after that




I was getting Permission denied on everything I was doing(even using
ls or cd)




So I exited my connection(using cygwin) and tried to re-connect but now I get




Permission denied (publickey,gssapi-keyex,gssapi-with-mic)




I tried setting chmod 400 my.pem , chmod 600 my.pem, chmod 777 my.pem but nothing worked.

I am trying to connect using ssh -i my.pem ec2-user@xx.xx.xx.x which was working fine earlier.

What is the solution?







linux amazon-web-services amazon-ec2






share|improve this question







New contributor




iAmLearning is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




iAmLearning is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




iAmLearning is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 6 hours ago









iAmLearningiAmLearning

1162




1162




New contributor




iAmLearning is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





iAmLearning is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






iAmLearning is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • I have installed so many things on my instance. I don't want to loose it. Is there any way to get it back ?

    – iAmLearning
    6 hours ago






  • 3





    You should be using EBS snapshots to ensure you can recover your instance to a point in time that it's working. The advice from MLu below is what I'd have said too. Don't experiment on servers that have important data. I did something similar on my EC2 instance when I was learning, I had to restore to a snapshot because it was far too difficult to fix.

    – Tim
    5 hours ago



















  • I have installed so many things on my instance. I don't want to loose it. Is there any way to get it back ?

    – iAmLearning
    6 hours ago






  • 3





    You should be using EBS snapshots to ensure you can recover your instance to a point in time that it's working. The advice from MLu below is what I'd have said too. Don't experiment on servers that have important data. I did something similar on my EC2 instance when I was learning, I had to restore to a snapshot because it was far too difficult to fix.

    – Tim
    5 hours ago

















I have installed so many things on my instance. I don't want to loose it. Is there any way to get it back ?

– iAmLearning
6 hours ago





I have installed so many things on my instance. I don't want to loose it. Is there any way to get it back ?

– iAmLearning
6 hours ago




3




3





You should be using EBS snapshots to ensure you can recover your instance to a point in time that it's working. The advice from MLu below is what I'd have said too. Don't experiment on servers that have important data. I did something similar on my EC2 instance when I was learning, I had to restore to a snapshot because it was far too difficult to fix.

– Tim
5 hours ago





You should be using EBS snapshots to ensure you can recover your instance to a point in time that it's working. The advice from MLu below is what I'd have said too. Don't experiment on servers that have important data. I did something similar on my EC2 instance when I was learning, I had to restore to a snapshot because it was far too difficult to fix.

– Tim
5 hours ago










2 Answers
2






active

oldest

votes


















7














Solution is to start a new instance and never do what you did again. It would be too complicated to try to properly recover all the permissions that you reset to 2770.



If you have any valuable files on the broken instance you can stop it, mount its root volume to the new instance and copy the files from there.





Update: as @GeraldSchneider points out you may be lucky if you didn't recursively change all the permissions everywhere. You'll have to start a new instance and use it to fix the root permissions back to 0755. Follow for example the instructions here: Changed AWS EC2 firewall rule and locked out of ssh (instead of Fix the firewall do sudo chmod 755 /mnt or wherever you mount the other disk).



Hope that helps :)






share|improve this answer





















  • 1





    My first thought was to rebuild the instance as well, but then I realized that the OP only changed the permission on / itself, not the directories and files below. It should be pretty easy to fix this, but I'm not familiar with EC2 and don't know how to mount the volume on a different instance.

    – Gerald Schneider
    5 hours ago











  • Is rebuilding possible ? I am just learning ec2 so I don't care about permissions/security. I just need it working again if possible.

    – iAmLearning
    5 hours ago











  • @GeraldSchneider good point, updated the answer.

    – MLu
    5 hours ago



















0














What you did was make every file in the filesystem a 2770 permission.



-rwxrws--- 1 username  agroup  2 Feb 19 23:07 thefilename


Thats a sticky bit in the group column, which means all files inside a directory are owned by agroup.





I've never bjorked an AWS image quite that badly. But I've seen a few probs that kill them.



FIRST Revert to your last snapshot, before hosing the file modes.




You don't do periodic snapshots?




SECOND Look at your backups. Is it going to be more or less work to rebuild the box vs restore your data from backups?




What? You don't have backups either?




Then the last ditch standard recovery method would be something like:




  1. Create a new instance from a current AMI, ideally the same distro as your broken machine. It can be something small like a t3.nano

  2. Detach the volumes from your broken machine, and attach them to the new instance as sdf, g, h... and so on


  3. Log into your new instance as root and for each of your broken instance's disks run



    fsck /dev/xvdX
    mkdir /sdX
    mount /dev/xvdX /sdX
    cd /sdX
    ls -l


  4. At this point you need to decide whether its worth using chmod over and over to fix your problem, or whether you copy the data to your new instance and set it up over again.


  5. So manually change into each directory, and chmod each file to what it should be. Keep two windows open and compare the live host's files with the broken disks mounted. Make sure you're changing the RIGHT files - check often!!!


  6. When you've done the lot, shut down the temp machine, detach the disks in the EC2 web gui and then reattach them to the old machine, in the same mountpoints from which they came. NOTE the root drive is attached as sda1 not sda but all other volumes are attached as sdb through z.





Either way, you should set up automated snapshots or backups, or both!



To prevent yourself doing this exact same thing again, alias chmod to



 chmod --preserve-root


But this won't protect any other directory.



Also don't use sudo in front of commands just by habit.






share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "2"
    };
    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
    });


    }
    });






    iAmLearning is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f954623%2funable-to-login-to-ec2-instance-after-running-sudo-chmod-2770%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









    7














    Solution is to start a new instance and never do what you did again. It would be too complicated to try to properly recover all the permissions that you reset to 2770.



    If you have any valuable files on the broken instance you can stop it, mount its root volume to the new instance and copy the files from there.





    Update: as @GeraldSchneider points out you may be lucky if you didn't recursively change all the permissions everywhere. You'll have to start a new instance and use it to fix the root permissions back to 0755. Follow for example the instructions here: Changed AWS EC2 firewall rule and locked out of ssh (instead of Fix the firewall do sudo chmod 755 /mnt or wherever you mount the other disk).



    Hope that helps :)






    share|improve this answer





















    • 1





      My first thought was to rebuild the instance as well, but then I realized that the OP only changed the permission on / itself, not the directories and files below. It should be pretty easy to fix this, but I'm not familiar with EC2 and don't know how to mount the volume on a different instance.

      – Gerald Schneider
      5 hours ago











    • Is rebuilding possible ? I am just learning ec2 so I don't care about permissions/security. I just need it working again if possible.

      – iAmLearning
      5 hours ago











    • @GeraldSchneider good point, updated the answer.

      – MLu
      5 hours ago
















    7














    Solution is to start a new instance and never do what you did again. It would be too complicated to try to properly recover all the permissions that you reset to 2770.



    If you have any valuable files on the broken instance you can stop it, mount its root volume to the new instance and copy the files from there.





    Update: as @GeraldSchneider points out you may be lucky if you didn't recursively change all the permissions everywhere. You'll have to start a new instance and use it to fix the root permissions back to 0755. Follow for example the instructions here: Changed AWS EC2 firewall rule and locked out of ssh (instead of Fix the firewall do sudo chmod 755 /mnt or wherever you mount the other disk).



    Hope that helps :)






    share|improve this answer





















    • 1





      My first thought was to rebuild the instance as well, but then I realized that the OP only changed the permission on / itself, not the directories and files below. It should be pretty easy to fix this, but I'm not familiar with EC2 and don't know how to mount the volume on a different instance.

      – Gerald Schneider
      5 hours ago











    • Is rebuilding possible ? I am just learning ec2 so I don't care about permissions/security. I just need it working again if possible.

      – iAmLearning
      5 hours ago











    • @GeraldSchneider good point, updated the answer.

      – MLu
      5 hours ago














    7












    7








    7







    Solution is to start a new instance and never do what you did again. It would be too complicated to try to properly recover all the permissions that you reset to 2770.



    If you have any valuable files on the broken instance you can stop it, mount its root volume to the new instance and copy the files from there.





    Update: as @GeraldSchneider points out you may be lucky if you didn't recursively change all the permissions everywhere. You'll have to start a new instance and use it to fix the root permissions back to 0755. Follow for example the instructions here: Changed AWS EC2 firewall rule and locked out of ssh (instead of Fix the firewall do sudo chmod 755 /mnt or wherever you mount the other disk).



    Hope that helps :)






    share|improve this answer















    Solution is to start a new instance and never do what you did again. It would be too complicated to try to properly recover all the permissions that you reset to 2770.



    If you have any valuable files on the broken instance you can stop it, mount its root volume to the new instance and copy the files from there.





    Update: as @GeraldSchneider points out you may be lucky if you didn't recursively change all the permissions everywhere. You'll have to start a new instance and use it to fix the root permissions back to 0755. Follow for example the instructions here: Changed AWS EC2 firewall rule and locked out of ssh (instead of Fix the firewall do sudo chmod 755 /mnt or wherever you mount the other disk).



    Hope that helps :)







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 5 hours ago

























    answered 5 hours ago









    MLuMLu

    8,26712141




    8,26712141








    • 1





      My first thought was to rebuild the instance as well, but then I realized that the OP only changed the permission on / itself, not the directories and files below. It should be pretty easy to fix this, but I'm not familiar with EC2 and don't know how to mount the volume on a different instance.

      – Gerald Schneider
      5 hours ago











    • Is rebuilding possible ? I am just learning ec2 so I don't care about permissions/security. I just need it working again if possible.

      – iAmLearning
      5 hours ago











    • @GeraldSchneider good point, updated the answer.

      – MLu
      5 hours ago














    • 1





      My first thought was to rebuild the instance as well, but then I realized that the OP only changed the permission on / itself, not the directories and files below. It should be pretty easy to fix this, but I'm not familiar with EC2 and don't know how to mount the volume on a different instance.

      – Gerald Schneider
      5 hours ago











    • Is rebuilding possible ? I am just learning ec2 so I don't care about permissions/security. I just need it working again if possible.

      – iAmLearning
      5 hours ago











    • @GeraldSchneider good point, updated the answer.

      – MLu
      5 hours ago








    1




    1





    My first thought was to rebuild the instance as well, but then I realized that the OP only changed the permission on / itself, not the directories and files below. It should be pretty easy to fix this, but I'm not familiar with EC2 and don't know how to mount the volume on a different instance.

    – Gerald Schneider
    5 hours ago





    My first thought was to rebuild the instance as well, but then I realized that the OP only changed the permission on / itself, not the directories and files below. It should be pretty easy to fix this, but I'm not familiar with EC2 and don't know how to mount the volume on a different instance.

    – Gerald Schneider
    5 hours ago













    Is rebuilding possible ? I am just learning ec2 so I don't care about permissions/security. I just need it working again if possible.

    – iAmLearning
    5 hours ago





    Is rebuilding possible ? I am just learning ec2 so I don't care about permissions/security. I just need it working again if possible.

    – iAmLearning
    5 hours ago













    @GeraldSchneider good point, updated the answer.

    – MLu
    5 hours ago





    @GeraldSchneider good point, updated the answer.

    – MLu
    5 hours ago













    0














    What you did was make every file in the filesystem a 2770 permission.



    -rwxrws--- 1 username  agroup  2 Feb 19 23:07 thefilename


    Thats a sticky bit in the group column, which means all files inside a directory are owned by agroup.





    I've never bjorked an AWS image quite that badly. But I've seen a few probs that kill them.



    FIRST Revert to your last snapshot, before hosing the file modes.




    You don't do periodic snapshots?




    SECOND Look at your backups. Is it going to be more or less work to rebuild the box vs restore your data from backups?




    What? You don't have backups either?




    Then the last ditch standard recovery method would be something like:




    1. Create a new instance from a current AMI, ideally the same distro as your broken machine. It can be something small like a t3.nano

    2. Detach the volumes from your broken machine, and attach them to the new instance as sdf, g, h... and so on


    3. Log into your new instance as root and for each of your broken instance's disks run



      fsck /dev/xvdX
      mkdir /sdX
      mount /dev/xvdX /sdX
      cd /sdX
      ls -l


    4. At this point you need to decide whether its worth using chmod over and over to fix your problem, or whether you copy the data to your new instance and set it up over again.


    5. So manually change into each directory, and chmod each file to what it should be. Keep two windows open and compare the live host's files with the broken disks mounted. Make sure you're changing the RIGHT files - check often!!!


    6. When you've done the lot, shut down the temp machine, detach the disks in the EC2 web gui and then reattach them to the old machine, in the same mountpoints from which they came. NOTE the root drive is attached as sda1 not sda but all other volumes are attached as sdb through z.





    Either way, you should set up automated snapshots or backups, or both!



    To prevent yourself doing this exact same thing again, alias chmod to



     chmod --preserve-root


    But this won't protect any other directory.



    Also don't use sudo in front of commands just by habit.






    share|improve this answer






























      0














      What you did was make every file in the filesystem a 2770 permission.



      -rwxrws--- 1 username  agroup  2 Feb 19 23:07 thefilename


      Thats a sticky bit in the group column, which means all files inside a directory are owned by agroup.





      I've never bjorked an AWS image quite that badly. But I've seen a few probs that kill them.



      FIRST Revert to your last snapshot, before hosing the file modes.




      You don't do periodic snapshots?




      SECOND Look at your backups. Is it going to be more or less work to rebuild the box vs restore your data from backups?




      What? You don't have backups either?




      Then the last ditch standard recovery method would be something like:




      1. Create a new instance from a current AMI, ideally the same distro as your broken machine. It can be something small like a t3.nano

      2. Detach the volumes from your broken machine, and attach them to the new instance as sdf, g, h... and so on


      3. Log into your new instance as root and for each of your broken instance's disks run



        fsck /dev/xvdX
        mkdir /sdX
        mount /dev/xvdX /sdX
        cd /sdX
        ls -l


      4. At this point you need to decide whether its worth using chmod over and over to fix your problem, or whether you copy the data to your new instance and set it up over again.


      5. So manually change into each directory, and chmod each file to what it should be. Keep two windows open and compare the live host's files with the broken disks mounted. Make sure you're changing the RIGHT files - check often!!!


      6. When you've done the lot, shut down the temp machine, detach the disks in the EC2 web gui and then reattach them to the old machine, in the same mountpoints from which they came. NOTE the root drive is attached as sda1 not sda but all other volumes are attached as sdb through z.





      Either way, you should set up automated snapshots or backups, or both!



      To prevent yourself doing this exact same thing again, alias chmod to



       chmod --preserve-root


      But this won't protect any other directory.



      Also don't use sudo in front of commands just by habit.






      share|improve this answer




























        0












        0








        0







        What you did was make every file in the filesystem a 2770 permission.



        -rwxrws--- 1 username  agroup  2 Feb 19 23:07 thefilename


        Thats a sticky bit in the group column, which means all files inside a directory are owned by agroup.





        I've never bjorked an AWS image quite that badly. But I've seen a few probs that kill them.



        FIRST Revert to your last snapshot, before hosing the file modes.




        You don't do periodic snapshots?




        SECOND Look at your backups. Is it going to be more or less work to rebuild the box vs restore your data from backups?




        What? You don't have backups either?




        Then the last ditch standard recovery method would be something like:




        1. Create a new instance from a current AMI, ideally the same distro as your broken machine. It can be something small like a t3.nano

        2. Detach the volumes from your broken machine, and attach them to the new instance as sdf, g, h... and so on


        3. Log into your new instance as root and for each of your broken instance's disks run



          fsck /dev/xvdX
          mkdir /sdX
          mount /dev/xvdX /sdX
          cd /sdX
          ls -l


        4. At this point you need to decide whether its worth using chmod over and over to fix your problem, or whether you copy the data to your new instance and set it up over again.


        5. So manually change into each directory, and chmod each file to what it should be. Keep two windows open and compare the live host's files with the broken disks mounted. Make sure you're changing the RIGHT files - check often!!!


        6. When you've done the lot, shut down the temp machine, detach the disks in the EC2 web gui and then reattach them to the old machine, in the same mountpoints from which they came. NOTE the root drive is attached as sda1 not sda but all other volumes are attached as sdb through z.





        Either way, you should set up automated snapshots or backups, or both!



        To prevent yourself doing this exact same thing again, alias chmod to



         chmod --preserve-root


        But this won't protect any other directory.



        Also don't use sudo in front of commands just by habit.






        share|improve this answer















        What you did was make every file in the filesystem a 2770 permission.



        -rwxrws--- 1 username  agroup  2 Feb 19 23:07 thefilename


        Thats a sticky bit in the group column, which means all files inside a directory are owned by agroup.





        I've never bjorked an AWS image quite that badly. But I've seen a few probs that kill them.



        FIRST Revert to your last snapshot, before hosing the file modes.




        You don't do periodic snapshots?




        SECOND Look at your backups. Is it going to be more or less work to rebuild the box vs restore your data from backups?




        What? You don't have backups either?




        Then the last ditch standard recovery method would be something like:




        1. Create a new instance from a current AMI, ideally the same distro as your broken machine. It can be something small like a t3.nano

        2. Detach the volumes from your broken machine, and attach them to the new instance as sdf, g, h... and so on


        3. Log into your new instance as root and for each of your broken instance's disks run



          fsck /dev/xvdX
          mkdir /sdX
          mount /dev/xvdX /sdX
          cd /sdX
          ls -l


        4. At this point you need to decide whether its worth using chmod over and over to fix your problem, or whether you copy the data to your new instance and set it up over again.


        5. So manually change into each directory, and chmod each file to what it should be. Keep two windows open and compare the live host's files with the broken disks mounted. Make sure you're changing the RIGHT files - check often!!!


        6. When you've done the lot, shut down the temp machine, detach the disks in the EC2 web gui and then reattach them to the old machine, in the same mountpoints from which they came. NOTE the root drive is attached as sda1 not sda but all other volumes are attached as sdb through z.





        Either way, you should set up automated snapshots or backups, or both!



        To prevent yourself doing this exact same thing again, alias chmod to



         chmod --preserve-root


        But this won't protect any other directory.



        Also don't use sudo in front of commands just by habit.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 hours ago

























        answered 3 hours ago









        CriggieCriggie

        1,090619




        1,090619






















            iAmLearning is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            iAmLearning is a new contributor. Be nice, and check out our Code of Conduct.













            iAmLearning is a new contributor. Be nice, and check out our Code of Conduct.












            iAmLearning is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Server Fault!


            • 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%2fserverfault.com%2fquestions%2f954623%2funable-to-login-to-ec2-instance-after-running-sudo-chmod-2770%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

            Anexo:Material bélico de la Fuerza Aérea de Chile Índice Aeronaves Defensa...

            Always On Availability groups resolving state after failover - Remote harden of transaction...

            update json value to null Announcing the arrival of Valued Associate #679: Cesar Manara ...