How to set up SSH key for git on Windows 10 Ubuntu subsystem











up vote
0
down vote

favorite












I'm using the ubuntu bash (subsystem) on windows 10 as my shell. I have a gitlab git repository that I cloned. When I use the git from this shell it is separate from my windows git and I'm unable to make it use my SSH key. It just keeps asking for my user/pass. Note that the SSH key is configured correctly in gitlab.



I place my id_rsa and id_rsa.pub in ~/.ssh/ (ubuntu subsystem path)



Any idea?










share|improve this question
























  • start the ssh-agent with eval 'ssh-agent -s' then load your key with ssh-add. If files permissions and the key is setup on gitlab this should work.
    – xaa
    Nov 28 at 16:06












  • @xaa , I tried it before, but it doesn't work. By the way, ssh-add works only with eval `ssh-agent -s` and not eval 'ssh-agent -s' (different quotes char). I'm able to add id_rsa with ssh-add but git still asks for user/pass.
    – chef
    Nov 29 at 9:21

















up vote
0
down vote

favorite












I'm using the ubuntu bash (subsystem) on windows 10 as my shell. I have a gitlab git repository that I cloned. When I use the git from this shell it is separate from my windows git and I'm unable to make it use my SSH key. It just keeps asking for my user/pass. Note that the SSH key is configured correctly in gitlab.



I place my id_rsa and id_rsa.pub in ~/.ssh/ (ubuntu subsystem path)



Any idea?










share|improve this question
























  • start the ssh-agent with eval 'ssh-agent -s' then load your key with ssh-add. If files permissions and the key is setup on gitlab this should work.
    – xaa
    Nov 28 at 16:06












  • @xaa , I tried it before, but it doesn't work. By the way, ssh-add works only with eval `ssh-agent -s` and not eval 'ssh-agent -s' (different quotes char). I'm able to add id_rsa with ssh-add but git still asks for user/pass.
    – chef
    Nov 29 at 9:21















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm using the ubuntu bash (subsystem) on windows 10 as my shell. I have a gitlab git repository that I cloned. When I use the git from this shell it is separate from my windows git and I'm unable to make it use my SSH key. It just keeps asking for my user/pass. Note that the SSH key is configured correctly in gitlab.



I place my id_rsa and id_rsa.pub in ~/.ssh/ (ubuntu subsystem path)



Any idea?










share|improve this question















I'm using the ubuntu bash (subsystem) on windows 10 as my shell. I have a gitlab git repository that I cloned. When I use the git from this shell it is separate from my windows git and I'm unable to make it use my SSH key. It just keeps asking for my user/pass. Note that the SSH key is configured correctly in gitlab.



I place my id_rsa and id_rsa.pub in ~/.ssh/ (ubuntu subsystem path)



Any idea?







ssh git windows-subsystem-for-linux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 at 14:39

























asked Nov 28 at 12:17









chef

18213




18213












  • start the ssh-agent with eval 'ssh-agent -s' then load your key with ssh-add. If files permissions and the key is setup on gitlab this should work.
    – xaa
    Nov 28 at 16:06












  • @xaa , I tried it before, but it doesn't work. By the way, ssh-add works only with eval `ssh-agent -s` and not eval 'ssh-agent -s' (different quotes char). I'm able to add id_rsa with ssh-add but git still asks for user/pass.
    – chef
    Nov 29 at 9:21




















  • start the ssh-agent with eval 'ssh-agent -s' then load your key with ssh-add. If files permissions and the key is setup on gitlab this should work.
    – xaa
    Nov 28 at 16:06












  • @xaa , I tried it before, but it doesn't work. By the way, ssh-add works only with eval `ssh-agent -s` and not eval 'ssh-agent -s' (different quotes char). I'm able to add id_rsa with ssh-add but git still asks for user/pass.
    – chef
    Nov 29 at 9:21


















start the ssh-agent with eval 'ssh-agent -s' then load your key with ssh-add. If files permissions and the key is setup on gitlab this should work.
– xaa
Nov 28 at 16:06






start the ssh-agent with eval 'ssh-agent -s' then load your key with ssh-add. If files permissions and the key is setup on gitlab this should work.
– xaa
Nov 28 at 16:06














@xaa , I tried it before, but it doesn't work. By the way, ssh-add works only with eval `ssh-agent -s` and not eval 'ssh-agent -s' (different quotes char). I'm able to add id_rsa with ssh-add but git still asks for user/pass.
– chef
Nov 29 at 9:21






@xaa , I tried it before, but it doesn't work. By the way, ssh-add works only with eval `ssh-agent -s` and not eval 'ssh-agent -s' (different quotes char). I'm able to add id_rsa with ssh-add but git still asks for user/pass.
– chef
Nov 29 at 9:21












2 Answers
2






active

oldest

votes

















up vote
0
down vote













OK, I found the problem. I was using an https:// url for the origin instead of an ssh url (git@gitlab.com:...). After switching to an ssh url the ssh key was used.



To view current remotes: git remote -v



To switch a remote: git remote set-url origin git@gitlab.com:XXXXX






share|improve this answer




























    up vote
    -1
    down vote













    Use this command:



    ssh-copy-id username@server.domain.com


    Change the user to your username, and target to your destination, so it will copy your ssh key to the target system.






    share|improve this answer























    • If I understand correctly, ssh-copy-id is for adding the key on the server. I already have the key on the server. I also have it on my device under ~/.ssh/ . The problem here is that the key on my device is not used.
      – chef
      Nov 28 at 14:38










    • Thanks @davidbaumann ! Next time I'll be more accurate!
      – Peredat0r
      Nov 28 at 14:38










    • @Chef then delete your key from the server, maybe it has some formatting problems, if you pasted it manually. this command will do the work for you. :) I had the same issue, and this command did help me out.
      – Peredat0r
      Nov 28 at 14:42










    • you can also add -v, so it will show you the authentication methods it's trying.
      – davidbaumann
      Nov 28 at 15:29











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379069%2fhow-to-set-up-ssh-key-for-git-on-windows-10-ubuntu-subsystem%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








    up vote
    0
    down vote













    OK, I found the problem. I was using an https:// url for the origin instead of an ssh url (git@gitlab.com:...). After switching to an ssh url the ssh key was used.



    To view current remotes: git remote -v



    To switch a remote: git remote set-url origin git@gitlab.com:XXXXX






    share|improve this answer

























      up vote
      0
      down vote













      OK, I found the problem. I was using an https:// url for the origin instead of an ssh url (git@gitlab.com:...). After switching to an ssh url the ssh key was used.



      To view current remotes: git remote -v



      To switch a remote: git remote set-url origin git@gitlab.com:XXXXX






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        OK, I found the problem. I was using an https:// url for the origin instead of an ssh url (git@gitlab.com:...). After switching to an ssh url the ssh key was used.



        To view current remotes: git remote -v



        To switch a remote: git remote set-url origin git@gitlab.com:XXXXX






        share|improve this answer












        OK, I found the problem. I was using an https:// url for the origin instead of an ssh url (git@gitlab.com:...). After switching to an ssh url the ssh key was used.



        To view current remotes: git remote -v



        To switch a remote: git remote set-url origin git@gitlab.com:XXXXX







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 29 at 9:44









        chef

        18213




        18213
























            up vote
            -1
            down vote













            Use this command:



            ssh-copy-id username@server.domain.com


            Change the user to your username, and target to your destination, so it will copy your ssh key to the target system.






            share|improve this answer























            • If I understand correctly, ssh-copy-id is for adding the key on the server. I already have the key on the server. I also have it on my device under ~/.ssh/ . The problem here is that the key on my device is not used.
              – chef
              Nov 28 at 14:38










            • Thanks @davidbaumann ! Next time I'll be more accurate!
              – Peredat0r
              Nov 28 at 14:38










            • @Chef then delete your key from the server, maybe it has some formatting problems, if you pasted it manually. this command will do the work for you. :) I had the same issue, and this command did help me out.
              – Peredat0r
              Nov 28 at 14:42










            • you can also add -v, so it will show you the authentication methods it's trying.
              – davidbaumann
              Nov 28 at 15:29















            up vote
            -1
            down vote













            Use this command:



            ssh-copy-id username@server.domain.com


            Change the user to your username, and target to your destination, so it will copy your ssh key to the target system.






            share|improve this answer























            • If I understand correctly, ssh-copy-id is for adding the key on the server. I already have the key on the server. I also have it on my device under ~/.ssh/ . The problem here is that the key on my device is not used.
              – chef
              Nov 28 at 14:38










            • Thanks @davidbaumann ! Next time I'll be more accurate!
              – Peredat0r
              Nov 28 at 14:38










            • @Chef then delete your key from the server, maybe it has some formatting problems, if you pasted it manually. this command will do the work for you. :) I had the same issue, and this command did help me out.
              – Peredat0r
              Nov 28 at 14:42










            • you can also add -v, so it will show you the authentication methods it's trying.
              – davidbaumann
              Nov 28 at 15:29













            up vote
            -1
            down vote










            up vote
            -1
            down vote









            Use this command:



            ssh-copy-id username@server.domain.com


            Change the user to your username, and target to your destination, so it will copy your ssh key to the target system.






            share|improve this answer














            Use this command:



            ssh-copy-id username@server.domain.com


            Change the user to your username, and target to your destination, so it will copy your ssh key to the target system.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 28 at 13:01









            davidbaumann

            1,832722




            1,832722










            answered Nov 28 at 12:52









            Peredat0r

            1




            1












            • If I understand correctly, ssh-copy-id is for adding the key on the server. I already have the key on the server. I also have it on my device under ~/.ssh/ . The problem here is that the key on my device is not used.
              – chef
              Nov 28 at 14:38










            • Thanks @davidbaumann ! Next time I'll be more accurate!
              – Peredat0r
              Nov 28 at 14:38










            • @Chef then delete your key from the server, maybe it has some formatting problems, if you pasted it manually. this command will do the work for you. :) I had the same issue, and this command did help me out.
              – Peredat0r
              Nov 28 at 14:42










            • you can also add -v, so it will show you the authentication methods it's trying.
              – davidbaumann
              Nov 28 at 15:29


















            • If I understand correctly, ssh-copy-id is for adding the key on the server. I already have the key on the server. I also have it on my device under ~/.ssh/ . The problem here is that the key on my device is not used.
              – chef
              Nov 28 at 14:38










            • Thanks @davidbaumann ! Next time I'll be more accurate!
              – Peredat0r
              Nov 28 at 14:38










            • @Chef then delete your key from the server, maybe it has some formatting problems, if you pasted it manually. this command will do the work for you. :) I had the same issue, and this command did help me out.
              – Peredat0r
              Nov 28 at 14:42










            • you can also add -v, so it will show you the authentication methods it's trying.
              – davidbaumann
              Nov 28 at 15:29
















            If I understand correctly, ssh-copy-id is for adding the key on the server. I already have the key on the server. I also have it on my device under ~/.ssh/ . The problem here is that the key on my device is not used.
            – chef
            Nov 28 at 14:38




            If I understand correctly, ssh-copy-id is for adding the key on the server. I already have the key on the server. I also have it on my device under ~/.ssh/ . The problem here is that the key on my device is not used.
            – chef
            Nov 28 at 14:38












            Thanks @davidbaumann ! Next time I'll be more accurate!
            – Peredat0r
            Nov 28 at 14:38




            Thanks @davidbaumann ! Next time I'll be more accurate!
            – Peredat0r
            Nov 28 at 14:38












            @Chef then delete your key from the server, maybe it has some formatting problems, if you pasted it manually. this command will do the work for you. :) I had the same issue, and this command did help me out.
            – Peredat0r
            Nov 28 at 14:42




            @Chef then delete your key from the server, maybe it has some formatting problems, if you pasted it manually. this command will do the work for you. :) I had the same issue, and this command did help me out.
            – Peredat0r
            Nov 28 at 14:42












            you can also add -v, so it will show you the authentication methods it's trying.
            – davidbaumann
            Nov 28 at 15:29




            you can also add -v, so it will show you the authentication methods it's trying.
            – davidbaumann
            Nov 28 at 15:29


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379069%2fhow-to-set-up-ssh-key-for-git-on-windows-10-ubuntu-subsystem%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

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]