Unable to login to ec2 instance after running “sudo chmod 2770 /”
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
New contributor
add a comment |
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
New contributor
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
48 mins ago
1
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
16 mins ago
add a comment |
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
New contributor
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
linux amazon-web-services amazon-ec2
New contributor
New contributor
New contributor
asked 58 mins ago
iAmLearningiAmLearning
1062
1062
New contributor
New contributor
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
48 mins ago
1
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
16 mins ago
add a comment |
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
48 mins ago
1
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
16 mins 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
48 mins 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
48 mins ago
1
1
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
16 mins 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
16 mins ago
add a comment |
1 Answer
1
active
oldest
votes
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 :)
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
36 mins 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
19 mins ago
@GeraldSchneider good point, updated the answer.
– MLu
18 mins ago
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 :)
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
36 mins 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
19 mins ago
@GeraldSchneider good point, updated the answer.
– MLu
18 mins ago
add a comment |
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 :)
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
36 mins 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
19 mins ago
@GeraldSchneider good point, updated the answer.
– MLu
18 mins ago
add a comment |
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 :)
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 :)
edited 19 mins ago
answered 41 mins ago
MLuMLu
8,21712141
8,21712141
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
36 mins 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
19 mins ago
@GeraldSchneider good point, updated the answer.
– MLu
18 mins ago
add a comment |
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
36 mins 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
19 mins ago
@GeraldSchneider good point, updated the answer.
– MLu
18 mins 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
36 mins 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
36 mins 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
19 mins 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
19 mins ago
@GeraldSchneider good point, updated the answer.
– MLu
18 mins ago
@GeraldSchneider good point, updated the answer.
– MLu
18 mins ago
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
48 mins ago
1
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
16 mins ago