After changing permission of ~/.ssh/authorized_keys and the ~/.ssh directory I get a permission denied (public key)SSH Permission denied (publickey)SSH Permission denied (public key), but root ssh worksSSH “Permission Denied (Public Key)” Automatically re-occuring problemGetting prompted for a password via SSH even after setting up authorized_keysSSH Permission denied (using right password)Permission denied via ssh accessPublic key authentication Permission denied (publickey)ssh permission denied(public key)ssh login with public key stopped work in Ubuntu 16.04.4

Conflict between a religious belief that accounts for the existence of transgender people vs. one that doesn't

What color is a wolf's coat?

Heavy condensation inside car during winter. Tried multiple things, but no results!

Is there a coup going on in Bolivia?

Why in the world would the tab on a TO-220 package have a connection to anything (but GND, if applicable)?

What does Darth Vader think Obi-Wan's referring to when Obi says "If you strike me down..."

Outlining the climax made me lose interest in writing the actual story

How to respond to requests to retest, in hope that the bug is gone?

What happens when a ceramic bypass or decoupling capacitor goes bad?

A robot surviving on top of a 3x3 platform

Should I turn off kernel logging (and how?) if I'm running off an SSD?

Hanging string lights from stone

Does a small cup of coffee result in a 45% reduced blood flow to the brain?

Why is super hero technology never used by civilians?

C: Can't pass '#' as command-line argument

What is the communications range of a standard Starfleet combadge?

A novel about "helpful" woodlice aliens who eventually end up destroying every civilization they try to help

Crack hashed passwords using a known password

Single word for being half in this world, half in some other spooky plane of existence

Mostly pluses and minuses: says Grandpa

Does the German President's apology for WWII reflect the prevailing views of the people of Germany?

In an interview, is it self-defeating to say you use StackOverflow to find errors in code?

How do impulse response guitar amp simulators work?

Size Does Matter (at least referring to bottles)



After changing permission of ~/.ssh/authorized_keys and the ~/.ssh directory I get a permission denied (public key)


SSH Permission denied (publickey)SSH Permission denied (public key), but root ssh worksSSH “Permission Denied (Public Key)” Automatically re-occuring problemGetting prompted for a password via SSH even after setting up authorized_keysSSH Permission denied (using right password)Permission denied via ssh accessPublic key authentication Permission denied (publickey)ssh permission denied(public key)ssh login with public key stopped work in Ubuntu 16.04.4






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









0

















Without changing the permissions this error doesn't occur. I'm changing them with:



sudo chmod 700 ~/.ssh
sudo chmod 600 ~/.ssh/authorized_keys


(same steps as in this answer)










share|improve this question




























  • Why are you using sudo? are the files owned by root?

    – steeldriver
    Aug 11 at 11:32











  • @steeldriver Thanks for the reply It tells me permission denied if I don't use sudo. The authorized_keys is owned by root rw------- 1 root root 744 Aug 11 10:34 authorized_keys

    – Twiggeh
    Aug 11 at 16:10


















0

















Without changing the permissions this error doesn't occur. I'm changing them with:



sudo chmod 700 ~/.ssh
sudo chmod 600 ~/.ssh/authorized_keys


(same steps as in this answer)










share|improve this question




























  • Why are you using sudo? are the files owned by root?

    – steeldriver
    Aug 11 at 11:32











  • @steeldriver Thanks for the reply It tells me permission denied if I don't use sudo. The authorized_keys is owned by root rw------- 1 root root 744 Aug 11 10:34 authorized_keys

    – Twiggeh
    Aug 11 at 16:10














0












0








0


0






Without changing the permissions this error doesn't occur. I'm changing them with:



sudo chmod 700 ~/.ssh
sudo chmod 600 ~/.ssh/authorized_keys


(same steps as in this answer)










share|improve this question

















Without changing the permissions this error doesn't occur. I'm changing them with:



sudo chmod 700 ~/.ssh
sudo chmod 600 ~/.ssh/authorized_keys


(same steps as in this answer)







server permissions ssh






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








edited Aug 11 at 11:21









cmak.fr

4,0271 gold badge15 silver badges32 bronze badges




4,0271 gold badge15 silver badges32 bronze badges










asked Aug 11 at 11:13









TwiggehTwiggeh

31 bronze badge




31 bronze badge















  • Why are you using sudo? are the files owned by root?

    – steeldriver
    Aug 11 at 11:32











  • @steeldriver Thanks for the reply It tells me permission denied if I don't use sudo. The authorized_keys is owned by root rw------- 1 root root 744 Aug 11 10:34 authorized_keys

    – Twiggeh
    Aug 11 at 16:10


















  • Why are you using sudo? are the files owned by root?

    – steeldriver
    Aug 11 at 11:32











  • @steeldriver Thanks for the reply It tells me permission denied if I don't use sudo. The authorized_keys is owned by root rw------- 1 root root 744 Aug 11 10:34 authorized_keys

    – Twiggeh
    Aug 11 at 16:10

















Why are you using sudo? are the files owned by root?

– steeldriver
Aug 11 at 11:32





Why are you using sudo? are the files owned by root?

– steeldriver
Aug 11 at 11:32













@steeldriver Thanks for the reply It tells me permission denied if I don't use sudo. The authorized_keys is owned by root rw------- 1 root root 744 Aug 11 10:34 authorized_keys

– Twiggeh
Aug 11 at 16:10






@steeldriver Thanks for the reply It tells me permission denied if I don't use sudo. The authorized_keys is owned by root rw------- 1 root root 744 Aug 11 10:34 authorized_keys

– Twiggeh
Aug 11 at 16:10











2 Answers
2






active

oldest

votes


















1


















The problems are that the keys are owned by root.



sudo chown -R $USER:$USER ~/.ssh
chmod -R 700 ~/.ssh


These two commands will restore ownership to user and set permissions appropriately.



The general rule is that everything in your home directory should be owned by you. In the case of ssh keys, ssh will refuse to work if ownership does not match username, as it may be a security problem.






share|improve this answer


























  • I changed the permissions back with chown after steeldriver asked if they were owned by root and it still didn't work. Turned out that Digital Oceans console doesn't do well with copy pasting - it bummed my key up when I pasted it

    – Twiggeh
    Aug 12 at 10:16



















0


















In my case the answer was that the console provided by Digital Ocean bummed up my key when I pasted it in. (I don't know why it does that but long strings get scrambled when you paste them).



So the solution for me was to download the key file with curl.






share|improve this answer



























    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/4.0/"u003ecc by-sa 4.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%2f1164956%2fafter-changing-permission-of-ssh-authorized-keys-and-the-ssh-directory-i-g%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown


























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1


















    The problems are that the keys are owned by root.



    sudo chown -R $USER:$USER ~/.ssh
    chmod -R 700 ~/.ssh


    These two commands will restore ownership to user and set permissions appropriately.



    The general rule is that everything in your home directory should be owned by you. In the case of ssh keys, ssh will refuse to work if ownership does not match username, as it may be a security problem.






    share|improve this answer


























    • I changed the permissions back with chown after steeldriver asked if they were owned by root and it still didn't work. Turned out that Digital Oceans console doesn't do well with copy pasting - it bummed my key up when I pasted it

      – Twiggeh
      Aug 12 at 10:16
















    1


















    The problems are that the keys are owned by root.



    sudo chown -R $USER:$USER ~/.ssh
    chmod -R 700 ~/.ssh


    These two commands will restore ownership to user and set permissions appropriately.



    The general rule is that everything in your home directory should be owned by you. In the case of ssh keys, ssh will refuse to work if ownership does not match username, as it may be a security problem.






    share|improve this answer


























    • I changed the permissions back with chown after steeldriver asked if they were owned by root and it still didn't work. Turned out that Digital Oceans console doesn't do well with copy pasting - it bummed my key up when I pasted it

      – Twiggeh
      Aug 12 at 10:16














    1














    1










    1









    The problems are that the keys are owned by root.



    sudo chown -R $USER:$USER ~/.ssh
    chmod -R 700 ~/.ssh


    These two commands will restore ownership to user and set permissions appropriately.



    The general rule is that everything in your home directory should be owned by you. In the case of ssh keys, ssh will refuse to work if ownership does not match username, as it may be a security problem.






    share|improve this answer














    The problems are that the keys are owned by root.



    sudo chown -R $USER:$USER ~/.ssh
    chmod -R 700 ~/.ssh


    These two commands will restore ownership to user and set permissions appropriately.



    The general rule is that everything in your home directory should be owned by you. In the case of ssh keys, ssh will refuse to work if ownership does not match username, as it may be a security problem.







    share|improve this answer













    share|improve this answer




    share|improve this answer










    answered Aug 12 at 9:22









    vidarlovidarlo

    14.2k6 gold badges34 silver badges60 bronze badges




    14.2k6 gold badges34 silver badges60 bronze badges















    • I changed the permissions back with chown after steeldriver asked if they were owned by root and it still didn't work. Turned out that Digital Oceans console doesn't do well with copy pasting - it bummed my key up when I pasted it

      – Twiggeh
      Aug 12 at 10:16


















    • I changed the permissions back with chown after steeldriver asked if they were owned by root and it still didn't work. Turned out that Digital Oceans console doesn't do well with copy pasting - it bummed my key up when I pasted it

      – Twiggeh
      Aug 12 at 10:16

















    I changed the permissions back with chown after steeldriver asked if they were owned by root and it still didn't work. Turned out that Digital Oceans console doesn't do well with copy pasting - it bummed my key up when I pasted it

    – Twiggeh
    Aug 12 at 10:16






    I changed the permissions back with chown after steeldriver asked if they were owned by root and it still didn't work. Turned out that Digital Oceans console doesn't do well with copy pasting - it bummed my key up when I pasted it

    – Twiggeh
    Aug 12 at 10:16














    0


















    In my case the answer was that the console provided by Digital Ocean bummed up my key when I pasted it in. (I don't know why it does that but long strings get scrambled when you paste them).



    So the solution for me was to download the key file with curl.






    share|improve this answer






























      0


















      In my case the answer was that the console provided by Digital Ocean bummed up my key when I pasted it in. (I don't know why it does that but long strings get scrambled when you paste them).



      So the solution for me was to download the key file with curl.






      share|improve this answer




























        0














        0










        0









        In my case the answer was that the console provided by Digital Ocean bummed up my key when I pasted it in. (I don't know why it does that but long strings get scrambled when you paste them).



        So the solution for me was to download the key file with curl.






        share|improve this answer














        In my case the answer was that the console provided by Digital Ocean bummed up my key when I pasted it in. (I don't know why it does that but long strings get scrambled when you paste them).



        So the solution for me was to download the key file with curl.







        share|improve this answer













        share|improve this answer




        share|improve this answer










        answered Aug 12 at 10:20









        TwiggehTwiggeh

        31 bronze badge




        31 bronze badge































            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%2f1164956%2fafter-changing-permission-of-ssh-authorized-keys-and-the-ssh-directory-i-g%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

            Tamil (spriik) Luke uk diar | Nawigatjuun

            Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

            Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?