Permissions denied to owner, although it is set to 666 in .ssh directory












10















I recently messed around with the .ssh directory. Made some permission changes, I think and now it won't let me access it anymore. I can access it as the root user (sudo -i) but not as somesh



I get permission denied when listing or cding into .ssh even though it shows the files



ls: cannot access /home/somesh/.ssh/amazon.pem: Permission denied
ls: cannot access /home/somesh/.ssh/id_rsa: Permission denied
ls: cannot access /home/somesh/.ssh/known_hosts: Permission denied
ls: cannot access /home/somesh/.ssh/id_rsa.pub: Permission denied
total 0
-????????? ? ? ? ? ? amazon.pem
-????????? ? ? ? ? ? id_rsa
-????????? ? ? ? ? ? id_rsa.pub
-????????? ? ? ? ? ? known_hosts


Logging in as root and ls gives following results



# ls -l /home/somesh/ -a |grep ssh
drw-rw-rw- 2 somesh somesh 4096 Aug 27 15:45 .ssh


Even the files inside are .ssh are owned by somesh:somesh and chm



-rw-rw-rw- 1 somesh somesh 1692 Aug 27 15:45 amazon.pem
-rw-rw-rw- 1 somesh somesh 1675 Aug 25 20:01 id_rsa









share|improve this question


















  • 5





    See Why does chmod 644 make directories inaccessible?. AFAIK the correct permissions for the ~/.ssh directory is 700 (drwx------).

    – steeldriver
    Aug 27 '15 at 11:27
















10















I recently messed around with the .ssh directory. Made some permission changes, I think and now it won't let me access it anymore. I can access it as the root user (sudo -i) but not as somesh



I get permission denied when listing or cding into .ssh even though it shows the files



ls: cannot access /home/somesh/.ssh/amazon.pem: Permission denied
ls: cannot access /home/somesh/.ssh/id_rsa: Permission denied
ls: cannot access /home/somesh/.ssh/known_hosts: Permission denied
ls: cannot access /home/somesh/.ssh/id_rsa.pub: Permission denied
total 0
-????????? ? ? ? ? ? amazon.pem
-????????? ? ? ? ? ? id_rsa
-????????? ? ? ? ? ? id_rsa.pub
-????????? ? ? ? ? ? known_hosts


Logging in as root and ls gives following results



# ls -l /home/somesh/ -a |grep ssh
drw-rw-rw- 2 somesh somesh 4096 Aug 27 15:45 .ssh


Even the files inside are .ssh are owned by somesh:somesh and chm



-rw-rw-rw- 1 somesh somesh 1692 Aug 27 15:45 amazon.pem
-rw-rw-rw- 1 somesh somesh 1675 Aug 25 20:01 id_rsa









share|improve this question


















  • 5





    See Why does chmod 644 make directories inaccessible?. AFAIK the correct permissions for the ~/.ssh directory is 700 (drwx------).

    – steeldriver
    Aug 27 '15 at 11:27














10












10








10


1






I recently messed around with the .ssh directory. Made some permission changes, I think and now it won't let me access it anymore. I can access it as the root user (sudo -i) but not as somesh



I get permission denied when listing or cding into .ssh even though it shows the files



ls: cannot access /home/somesh/.ssh/amazon.pem: Permission denied
ls: cannot access /home/somesh/.ssh/id_rsa: Permission denied
ls: cannot access /home/somesh/.ssh/known_hosts: Permission denied
ls: cannot access /home/somesh/.ssh/id_rsa.pub: Permission denied
total 0
-????????? ? ? ? ? ? amazon.pem
-????????? ? ? ? ? ? id_rsa
-????????? ? ? ? ? ? id_rsa.pub
-????????? ? ? ? ? ? known_hosts


Logging in as root and ls gives following results



# ls -l /home/somesh/ -a |grep ssh
drw-rw-rw- 2 somesh somesh 4096 Aug 27 15:45 .ssh


Even the files inside are .ssh are owned by somesh:somesh and chm



-rw-rw-rw- 1 somesh somesh 1692 Aug 27 15:45 amazon.pem
-rw-rw-rw- 1 somesh somesh 1675 Aug 25 20:01 id_rsa









share|improve this question














I recently messed around with the .ssh directory. Made some permission changes, I think and now it won't let me access it anymore. I can access it as the root user (sudo -i) but not as somesh



I get permission denied when listing or cding into .ssh even though it shows the files



ls: cannot access /home/somesh/.ssh/amazon.pem: Permission denied
ls: cannot access /home/somesh/.ssh/id_rsa: Permission denied
ls: cannot access /home/somesh/.ssh/known_hosts: Permission denied
ls: cannot access /home/somesh/.ssh/id_rsa.pub: Permission denied
total 0
-????????? ? ? ? ? ? amazon.pem
-????????? ? ? ? ? ? id_rsa
-????????? ? ? ? ? ? id_rsa.pub
-????????? ? ? ? ? ? known_hosts


Logging in as root and ls gives following results



# ls -l /home/somesh/ -a |grep ssh
drw-rw-rw- 2 somesh somesh 4096 Aug 27 15:45 .ssh


Even the files inside are .ssh are owned by somesh:somesh and chm



-rw-rw-rw- 1 somesh somesh 1692 Aug 27 15:45 amazon.pem
-rw-rw-rw- 1 somesh somesh 1675 Aug 25 20:01 id_rsa






permissions ssh chmod






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Aug 27 '15 at 11:02









Somesh MukherjeeSomesh Mukherjee

161119




161119








  • 5





    See Why does chmod 644 make directories inaccessible?. AFAIK the correct permissions for the ~/.ssh directory is 700 (drwx------).

    – steeldriver
    Aug 27 '15 at 11:27














  • 5





    See Why does chmod 644 make directories inaccessible?. AFAIK the correct permissions for the ~/.ssh directory is 700 (drwx------).

    – steeldriver
    Aug 27 '15 at 11:27








5




5





See Why does chmod 644 make directories inaccessible?. AFAIK the correct permissions for the ~/.ssh directory is 700 (drwx------).

– steeldriver
Aug 27 '15 at 11:27





See Why does chmod 644 make directories inaccessible?. AFAIK the correct permissions for the ~/.ssh directory is 700 (drwx------).

– steeldriver
Aug 27 '15 at 11:27










3 Answers
3






active

oldest

votes


















16














Steeldriver is right. On directory you need also x access flag to be able to list files inside.



Fixing the directory using chmod 700 ~/.ssh should help you to get into this (correct) state:



$ ls -ld ~/.ssh
drwx------. 2 user user 4096 Aug 26 10:37 /home/user/.ssh


Also you should fix your keys using chmod 600 ~/.ssh/id_rsa and chmod 644 ~/.ssh/*.pub to get this:



$ ls -l ~/.ssh/
-rw-------. 1 user user 1766 Mar 7 2014 id_rsa
-rw-r--r--. 1 user user 415 Mar 7 2014 id_rsa.pub





share|improve this answer


























  • I managed to fix this before itself, by copying it somewhere else and then copying it back

    – Somesh Mukherjee
    Aug 29 '15 at 8:37



















0














I have the same issue , and I shut off the laptop thinking that, this is will solve the problem , ; I ended up in another problem which my password isn't open my computer any more :(



What shall I do ?help






share|improve this answer








New contributor




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




























    -2














    When you run command ls -l on any directory the first column is the permission column which is interpreted as follows:



    1-------------2 3 4-------5 6 7-------8 9 10



    (TYPE)----(user)-----(group)----(others)



    TYPE : If '-', it is a file. If 'd' it is a directory.



    Permissions: read: 4, write: 2, execute: 1



    So for read, write and execute your permissions will be 7 in user group.



    You can use



    sudo chmod 7 6 6 file_name 


    or



    sudo chmod -R u+x /home/somesh/.ssh 


    -R – this modifies the permission of the parent folder and the child objects within






    share|improve this answer





















    • 2





      I don't understand the TYPE part; also chmod 700 file_name and chmod u+x file_name do two completely different things. The first one sets the permissions to rwx/---/---, the second one just sets the x bit for the owner (and starting from 666 it will change the file to 766, not to 700).

      – kos
      Aug 27 '15 at 13:50








    • 1





      @kos, s/he means the first field in the string indicates the type of file entry. A - character means it's a "normal" file. A d means it is a directory. There are others, too, like c, l (for symbolic link), s, and even more for other OSes.

      – Josh
      Aug 28 '15 at 0:22











    • @Josh Yep, the layout confused me.

      – kos
      Aug 28 '15 at 3:45











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    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%2faskubuntu.com%2fquestions%2f666390%2fpermissions-denied-to-owner-although-it-is-set-to-666-in-ssh-directory%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    16














    Steeldriver is right. On directory you need also x access flag to be able to list files inside.



    Fixing the directory using chmod 700 ~/.ssh should help you to get into this (correct) state:



    $ ls -ld ~/.ssh
    drwx------. 2 user user 4096 Aug 26 10:37 /home/user/.ssh


    Also you should fix your keys using chmod 600 ~/.ssh/id_rsa and chmod 644 ~/.ssh/*.pub to get this:



    $ ls -l ~/.ssh/
    -rw-------. 1 user user 1766 Mar 7 2014 id_rsa
    -rw-r--r--. 1 user user 415 Mar 7 2014 id_rsa.pub





    share|improve this answer


























    • I managed to fix this before itself, by copying it somewhere else and then copying it back

      – Somesh Mukherjee
      Aug 29 '15 at 8:37
















    16














    Steeldriver is right. On directory you need also x access flag to be able to list files inside.



    Fixing the directory using chmod 700 ~/.ssh should help you to get into this (correct) state:



    $ ls -ld ~/.ssh
    drwx------. 2 user user 4096 Aug 26 10:37 /home/user/.ssh


    Also you should fix your keys using chmod 600 ~/.ssh/id_rsa and chmod 644 ~/.ssh/*.pub to get this:



    $ ls -l ~/.ssh/
    -rw-------. 1 user user 1766 Mar 7 2014 id_rsa
    -rw-r--r--. 1 user user 415 Mar 7 2014 id_rsa.pub





    share|improve this answer


























    • I managed to fix this before itself, by copying it somewhere else and then copying it back

      – Somesh Mukherjee
      Aug 29 '15 at 8:37














    16












    16








    16







    Steeldriver is right. On directory you need also x access flag to be able to list files inside.



    Fixing the directory using chmod 700 ~/.ssh should help you to get into this (correct) state:



    $ ls -ld ~/.ssh
    drwx------. 2 user user 4096 Aug 26 10:37 /home/user/.ssh


    Also you should fix your keys using chmod 600 ~/.ssh/id_rsa and chmod 644 ~/.ssh/*.pub to get this:



    $ ls -l ~/.ssh/
    -rw-------. 1 user user 1766 Mar 7 2014 id_rsa
    -rw-r--r--. 1 user user 415 Mar 7 2014 id_rsa.pub





    share|improve this answer















    Steeldriver is right. On directory you need also x access flag to be able to list files inside.



    Fixing the directory using chmod 700 ~/.ssh should help you to get into this (correct) state:



    $ ls -ld ~/.ssh
    drwx------. 2 user user 4096 Aug 26 10:37 /home/user/.ssh


    Also you should fix your keys using chmod 600 ~/.ssh/id_rsa and chmod 644 ~/.ssh/*.pub to get this:



    $ ls -l ~/.ssh/
    -rw-------. 1 user user 1766 Mar 7 2014 id_rsa
    -rw-r--r--. 1 user user 415 Mar 7 2014 id_rsa.pub






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Aug 28 '15 at 12:16

























    answered Aug 27 '15 at 11:33









    JakujeJakuje

    5,28471831




    5,28471831













    • I managed to fix this before itself, by copying it somewhere else and then copying it back

      – Somesh Mukherjee
      Aug 29 '15 at 8:37



















    • I managed to fix this before itself, by copying it somewhere else and then copying it back

      – Somesh Mukherjee
      Aug 29 '15 at 8:37

















    I managed to fix this before itself, by copying it somewhere else and then copying it back

    – Somesh Mukherjee
    Aug 29 '15 at 8:37





    I managed to fix this before itself, by copying it somewhere else and then copying it back

    – Somesh Mukherjee
    Aug 29 '15 at 8:37













    0














    I have the same issue , and I shut off the laptop thinking that, this is will solve the problem , ; I ended up in another problem which my password isn't open my computer any more :(



    What shall I do ?help






    share|improve this answer








    New contributor




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

























      0














      I have the same issue , and I shut off the laptop thinking that, this is will solve the problem , ; I ended up in another problem which my password isn't open my computer any more :(



      What shall I do ?help






      share|improve this answer








      New contributor




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























        0












        0








        0







        I have the same issue , and I shut off the laptop thinking that, this is will solve the problem , ; I ended up in another problem which my password isn't open my computer any more :(



        What shall I do ?help






        share|improve this answer








        New contributor




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










        I have the same issue , and I shut off the laptop thinking that, this is will solve the problem , ; I ended up in another problem which my password isn't open my computer any more :(



        What shall I do ?help







        share|improve this answer








        New contributor




        Abdul 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 answer



        share|improve this answer






        New contributor




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









        answered 1 hour ago









        AbdulAbdul

        1




        1




        New contributor




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





        New contributor





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






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























            -2














            When you run command ls -l on any directory the first column is the permission column which is interpreted as follows:



            1-------------2 3 4-------5 6 7-------8 9 10



            (TYPE)----(user)-----(group)----(others)



            TYPE : If '-', it is a file. If 'd' it is a directory.



            Permissions: read: 4, write: 2, execute: 1



            So for read, write and execute your permissions will be 7 in user group.



            You can use



            sudo chmod 7 6 6 file_name 


            or



            sudo chmod -R u+x /home/somesh/.ssh 


            -R – this modifies the permission of the parent folder and the child objects within






            share|improve this answer





















            • 2





              I don't understand the TYPE part; also chmod 700 file_name and chmod u+x file_name do two completely different things. The first one sets the permissions to rwx/---/---, the second one just sets the x bit for the owner (and starting from 666 it will change the file to 766, not to 700).

              – kos
              Aug 27 '15 at 13:50








            • 1





              @kos, s/he means the first field in the string indicates the type of file entry. A - character means it's a "normal" file. A d means it is a directory. There are others, too, like c, l (for symbolic link), s, and even more for other OSes.

              – Josh
              Aug 28 '15 at 0:22











            • @Josh Yep, the layout confused me.

              – kos
              Aug 28 '15 at 3:45
















            -2














            When you run command ls -l on any directory the first column is the permission column which is interpreted as follows:



            1-------------2 3 4-------5 6 7-------8 9 10



            (TYPE)----(user)-----(group)----(others)



            TYPE : If '-', it is a file. If 'd' it is a directory.



            Permissions: read: 4, write: 2, execute: 1



            So for read, write and execute your permissions will be 7 in user group.



            You can use



            sudo chmod 7 6 6 file_name 


            or



            sudo chmod -R u+x /home/somesh/.ssh 


            -R – this modifies the permission of the parent folder and the child objects within






            share|improve this answer





















            • 2





              I don't understand the TYPE part; also chmod 700 file_name and chmod u+x file_name do two completely different things. The first one sets the permissions to rwx/---/---, the second one just sets the x bit for the owner (and starting from 666 it will change the file to 766, not to 700).

              – kos
              Aug 27 '15 at 13:50








            • 1





              @kos, s/he means the first field in the string indicates the type of file entry. A - character means it's a "normal" file. A d means it is a directory. There are others, too, like c, l (for symbolic link), s, and even more for other OSes.

              – Josh
              Aug 28 '15 at 0:22











            • @Josh Yep, the layout confused me.

              – kos
              Aug 28 '15 at 3:45














            -2












            -2








            -2







            When you run command ls -l on any directory the first column is the permission column which is interpreted as follows:



            1-------------2 3 4-------5 6 7-------8 9 10



            (TYPE)----(user)-----(group)----(others)



            TYPE : If '-', it is a file. If 'd' it is a directory.



            Permissions: read: 4, write: 2, execute: 1



            So for read, write and execute your permissions will be 7 in user group.



            You can use



            sudo chmod 7 6 6 file_name 


            or



            sudo chmod -R u+x /home/somesh/.ssh 


            -R – this modifies the permission of the parent folder and the child objects within






            share|improve this answer















            When you run command ls -l on any directory the first column is the permission column which is interpreted as follows:



            1-------------2 3 4-------5 6 7-------8 9 10



            (TYPE)----(user)-----(group)----(others)



            TYPE : If '-', it is a file. If 'd' it is a directory.



            Permissions: read: 4, write: 2, execute: 1



            So for read, write and execute your permissions will be 7 in user group.



            You can use



            sudo chmod 7 6 6 file_name 


            or



            sudo chmod -R u+x /home/somesh/.ssh 


            -R – this modifies the permission of the parent folder and the child objects within







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 16 '16 at 13:42

























            answered Aug 27 '15 at 13:33









            Dhaval SimariaDhaval Simaria

            6492824




            6492824








            • 2





              I don't understand the TYPE part; also chmod 700 file_name and chmod u+x file_name do two completely different things. The first one sets the permissions to rwx/---/---, the second one just sets the x bit for the owner (and starting from 666 it will change the file to 766, not to 700).

              – kos
              Aug 27 '15 at 13:50








            • 1





              @kos, s/he means the first field in the string indicates the type of file entry. A - character means it's a "normal" file. A d means it is a directory. There are others, too, like c, l (for symbolic link), s, and even more for other OSes.

              – Josh
              Aug 28 '15 at 0:22











            • @Josh Yep, the layout confused me.

              – kos
              Aug 28 '15 at 3:45














            • 2





              I don't understand the TYPE part; also chmod 700 file_name and chmod u+x file_name do two completely different things. The first one sets the permissions to rwx/---/---, the second one just sets the x bit for the owner (and starting from 666 it will change the file to 766, not to 700).

              – kos
              Aug 27 '15 at 13:50








            • 1





              @kos, s/he means the first field in the string indicates the type of file entry. A - character means it's a "normal" file. A d means it is a directory. There are others, too, like c, l (for symbolic link), s, and even more for other OSes.

              – Josh
              Aug 28 '15 at 0:22











            • @Josh Yep, the layout confused me.

              – kos
              Aug 28 '15 at 3:45








            2




            2





            I don't understand the TYPE part; also chmod 700 file_name and chmod u+x file_name do two completely different things. The first one sets the permissions to rwx/---/---, the second one just sets the x bit for the owner (and starting from 666 it will change the file to 766, not to 700).

            – kos
            Aug 27 '15 at 13:50







            I don't understand the TYPE part; also chmod 700 file_name and chmod u+x file_name do two completely different things. The first one sets the permissions to rwx/---/---, the second one just sets the x bit for the owner (and starting from 666 it will change the file to 766, not to 700).

            – kos
            Aug 27 '15 at 13:50






            1




            1





            @kos, s/he means the first field in the string indicates the type of file entry. A - character means it's a "normal" file. A d means it is a directory. There are others, too, like c, l (for symbolic link), s, and even more for other OSes.

            – Josh
            Aug 28 '15 at 0:22





            @kos, s/he means the first field in the string indicates the type of file entry. A - character means it's a "normal" file. A d means it is a directory. There are others, too, like c, l (for symbolic link), s, and even more for other OSes.

            – Josh
            Aug 28 '15 at 0:22













            @Josh Yep, the layout confused me.

            – kos
            Aug 28 '15 at 3:45





            @Josh Yep, the layout confused me.

            – kos
            Aug 28 '15 at 3:45


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • 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%2faskubuntu.com%2fquestions%2f666390%2fpermissions-denied-to-owner-although-it-is-set-to-666-in-ssh-directory%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

            GameSpot

            日野市

            Tu-95轟炸機