ssh-copy-id permission denied












3














I'm trying to set up a git repo for a project and therefore I want to make use of ssh keys in order to not re-enter my password every time.
I stumbled over the possibility to let ssh do the copying work with ssh-copy-id, however it does not seem to work out for me.



$ ssh-copy-id -i git@server
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed:
"/c/Users/Me/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to
filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are
prompted now it is to install the new keys
git@server's password:
sh: 1: cannot create .ssh/authorized_keys: Permission denied


Edit: I solved the problem the following way:
- logged in root via su
- changed ownership of the authorized_keys file via chown git /home/git/.ssh/authorized keysto git
- then logged git back in
- lastly changed the rw permission to 600 via chmod 600 ~/.ssh/authorized keysand successfully copied the key over










share|improve this question
























  • Can you check permission of .ssh directory using ls -ld .ssh in the git server? The user and group ownership should be git:git and permission should be 700
    – Sourav
    Jun 25 '17 at 8:13












  • Seems like it: drwx------ 2 git git 4096 Jun 25 02:49 /home/git/.ssh
    – Tom Connery
    Jun 25 '17 at 9:45










  • Are you able to touch .ssh/authorized_keys on the server?
    – l0b0
    Jun 25 '17 at 9:48










  • git@rs000018:~$ touch .ssh/authorized_keys touch: cannot touch ‘.ssh/authorized_keys’: Permission denied Seems like a clear no =/
    – Tom Connery
    Jun 25 '17 at 12:28








  • 1




    Answers should go in the Answer box, not as an addendum to the question.
    – Jeff Schaller
    Jul 1 '17 at 17:14
















3














I'm trying to set up a git repo for a project and therefore I want to make use of ssh keys in order to not re-enter my password every time.
I stumbled over the possibility to let ssh do the copying work with ssh-copy-id, however it does not seem to work out for me.



$ ssh-copy-id -i git@server
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed:
"/c/Users/Me/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to
filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are
prompted now it is to install the new keys
git@server's password:
sh: 1: cannot create .ssh/authorized_keys: Permission denied


Edit: I solved the problem the following way:
- logged in root via su
- changed ownership of the authorized_keys file via chown git /home/git/.ssh/authorized keysto git
- then logged git back in
- lastly changed the rw permission to 600 via chmod 600 ~/.ssh/authorized keysand successfully copied the key over










share|improve this question
























  • Can you check permission of .ssh directory using ls -ld .ssh in the git server? The user and group ownership should be git:git and permission should be 700
    – Sourav
    Jun 25 '17 at 8:13












  • Seems like it: drwx------ 2 git git 4096 Jun 25 02:49 /home/git/.ssh
    – Tom Connery
    Jun 25 '17 at 9:45










  • Are you able to touch .ssh/authorized_keys on the server?
    – l0b0
    Jun 25 '17 at 9:48










  • git@rs000018:~$ touch .ssh/authorized_keys touch: cannot touch ‘.ssh/authorized_keys’: Permission denied Seems like a clear no =/
    – Tom Connery
    Jun 25 '17 at 12:28








  • 1




    Answers should go in the Answer box, not as an addendum to the question.
    – Jeff Schaller
    Jul 1 '17 at 17:14














3












3








3







I'm trying to set up a git repo for a project and therefore I want to make use of ssh keys in order to not re-enter my password every time.
I stumbled over the possibility to let ssh do the copying work with ssh-copy-id, however it does not seem to work out for me.



$ ssh-copy-id -i git@server
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed:
"/c/Users/Me/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to
filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are
prompted now it is to install the new keys
git@server's password:
sh: 1: cannot create .ssh/authorized_keys: Permission denied


Edit: I solved the problem the following way:
- logged in root via su
- changed ownership of the authorized_keys file via chown git /home/git/.ssh/authorized keysto git
- then logged git back in
- lastly changed the rw permission to 600 via chmod 600 ~/.ssh/authorized keysand successfully copied the key over










share|improve this question















I'm trying to set up a git repo for a project and therefore I want to make use of ssh keys in order to not re-enter my password every time.
I stumbled over the possibility to let ssh do the copying work with ssh-copy-id, however it does not seem to work out for me.



$ ssh-copy-id -i git@server
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed:
"/c/Users/Me/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to
filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are
prompted now it is to install the new keys
git@server's password:
sh: 1: cannot create .ssh/authorized_keys: Permission denied


Edit: I solved the problem the following way:
- logged in root via su
- changed ownership of the authorized_keys file via chown git /home/git/.ssh/authorized keysto git
- then logged git back in
- lastly changed the rw permission to 600 via chmod 600 ~/.ssh/authorized keysand successfully copied the key over







ssh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago









Rui F Ribeiro

39.2k1479130




39.2k1479130










asked Jun 25 '17 at 2:30









Tom Connery

1614




1614












  • Can you check permission of .ssh directory using ls -ld .ssh in the git server? The user and group ownership should be git:git and permission should be 700
    – Sourav
    Jun 25 '17 at 8:13












  • Seems like it: drwx------ 2 git git 4096 Jun 25 02:49 /home/git/.ssh
    – Tom Connery
    Jun 25 '17 at 9:45










  • Are you able to touch .ssh/authorized_keys on the server?
    – l0b0
    Jun 25 '17 at 9:48










  • git@rs000018:~$ touch .ssh/authorized_keys touch: cannot touch ‘.ssh/authorized_keys’: Permission denied Seems like a clear no =/
    – Tom Connery
    Jun 25 '17 at 12:28








  • 1




    Answers should go in the Answer box, not as an addendum to the question.
    – Jeff Schaller
    Jul 1 '17 at 17:14


















  • Can you check permission of .ssh directory using ls -ld .ssh in the git server? The user and group ownership should be git:git and permission should be 700
    – Sourav
    Jun 25 '17 at 8:13












  • Seems like it: drwx------ 2 git git 4096 Jun 25 02:49 /home/git/.ssh
    – Tom Connery
    Jun 25 '17 at 9:45










  • Are you able to touch .ssh/authorized_keys on the server?
    – l0b0
    Jun 25 '17 at 9:48










  • git@rs000018:~$ touch .ssh/authorized_keys touch: cannot touch ‘.ssh/authorized_keys’: Permission denied Seems like a clear no =/
    – Tom Connery
    Jun 25 '17 at 12:28








  • 1




    Answers should go in the Answer box, not as an addendum to the question.
    – Jeff Schaller
    Jul 1 '17 at 17:14
















Can you check permission of .ssh directory using ls -ld .ssh in the git server? The user and group ownership should be git:git and permission should be 700
– Sourav
Jun 25 '17 at 8:13






Can you check permission of .ssh directory using ls -ld .ssh in the git server? The user and group ownership should be git:git and permission should be 700
– Sourav
Jun 25 '17 at 8:13














Seems like it: drwx------ 2 git git 4096 Jun 25 02:49 /home/git/.ssh
– Tom Connery
Jun 25 '17 at 9:45




Seems like it: drwx------ 2 git git 4096 Jun 25 02:49 /home/git/.ssh
– Tom Connery
Jun 25 '17 at 9:45












Are you able to touch .ssh/authorized_keys on the server?
– l0b0
Jun 25 '17 at 9:48




Are you able to touch .ssh/authorized_keys on the server?
– l0b0
Jun 25 '17 at 9:48












git@rs000018:~$ touch .ssh/authorized_keys touch: cannot touch ‘.ssh/authorized_keys’: Permission denied Seems like a clear no =/
– Tom Connery
Jun 25 '17 at 12:28






git@rs000018:~$ touch .ssh/authorized_keys touch: cannot touch ‘.ssh/authorized_keys’: Permission denied Seems like a clear no =/
– Tom Connery
Jun 25 '17 at 12:28






1




1




Answers should go in the Answer box, not as an addendum to the question.
– Jeff Schaller
Jul 1 '17 at 17:14




Answers should go in the Answer box, not as an addendum to the question.
– Jeff Schaller
Jul 1 '17 at 17:14










2 Answers
2






active

oldest

votes


















2














If an account is dedicated to git usage, it makes sense for the administrator to make it a restricted account, only allowed to run git commands. In particular, git access should not be enough to change the credentials and restrictions on the account. This is done by having a ~/.ssh/authorized_keys that isn't writable by the user. There is usually an out-of-band mechanism to set up credentials, for example a web interface.



If you're the administrator, you need to dig in to find out how the git accounts are set up. Check the SSH server configuration (/etc/sshd_config or /etc/ssh/sshd_config to see where the authorized_keys files are located (AuthorizedKeysFile setting). Once you've found the file, add the public key to it: an authorized_keys files is just a list of line, each normally containing a public key copied straight from a .pub file. Check the configuration to see whether restrictions on the use of the key should be added at the end of the file (e.g. command="git-shell" nopty no-agent-forwarding no-port-forwarding no-X11-forwarding).






share|improve this answer





























    0














    Let us consider we have 2 machines, 'A' and 'B'
    Now you want to connect from A to 'B'



    So in B machine do the following



    vi /etc/ssh_sshd_config



    Now search for this two line and change to the following as shown below.



    PasswordAuthentication yes



    PermitRootLogin yes



    Now Restart the sshd service in 'B' machine



    service sshd restart



    Now copy the key from 'A' machine to 'B' machine and I hope it will Work fine



    ssh-copy-id root@154.34.22.109






    share|improve this answer





















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "106"
      };
      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: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      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%2funix.stackexchange.com%2fquestions%2f373210%2fssh-copy-id-permission-denied%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









      2














      If an account is dedicated to git usage, it makes sense for the administrator to make it a restricted account, only allowed to run git commands. In particular, git access should not be enough to change the credentials and restrictions on the account. This is done by having a ~/.ssh/authorized_keys that isn't writable by the user. There is usually an out-of-band mechanism to set up credentials, for example a web interface.



      If you're the administrator, you need to dig in to find out how the git accounts are set up. Check the SSH server configuration (/etc/sshd_config or /etc/ssh/sshd_config to see where the authorized_keys files are located (AuthorizedKeysFile setting). Once you've found the file, add the public key to it: an authorized_keys files is just a list of line, each normally containing a public key copied straight from a .pub file. Check the configuration to see whether restrictions on the use of the key should be added at the end of the file (e.g. command="git-shell" nopty no-agent-forwarding no-port-forwarding no-X11-forwarding).






      share|improve this answer


























        2














        If an account is dedicated to git usage, it makes sense for the administrator to make it a restricted account, only allowed to run git commands. In particular, git access should not be enough to change the credentials and restrictions on the account. This is done by having a ~/.ssh/authorized_keys that isn't writable by the user. There is usually an out-of-band mechanism to set up credentials, for example a web interface.



        If you're the administrator, you need to dig in to find out how the git accounts are set up. Check the SSH server configuration (/etc/sshd_config or /etc/ssh/sshd_config to see where the authorized_keys files are located (AuthorizedKeysFile setting). Once you've found the file, add the public key to it: an authorized_keys files is just a list of line, each normally containing a public key copied straight from a .pub file. Check the configuration to see whether restrictions on the use of the key should be added at the end of the file (e.g. command="git-shell" nopty no-agent-forwarding no-port-forwarding no-X11-forwarding).






        share|improve this answer
























          2












          2








          2






          If an account is dedicated to git usage, it makes sense for the administrator to make it a restricted account, only allowed to run git commands. In particular, git access should not be enough to change the credentials and restrictions on the account. This is done by having a ~/.ssh/authorized_keys that isn't writable by the user. There is usually an out-of-band mechanism to set up credentials, for example a web interface.



          If you're the administrator, you need to dig in to find out how the git accounts are set up. Check the SSH server configuration (/etc/sshd_config or /etc/ssh/sshd_config to see where the authorized_keys files are located (AuthorizedKeysFile setting). Once you've found the file, add the public key to it: an authorized_keys files is just a list of line, each normally containing a public key copied straight from a .pub file. Check the configuration to see whether restrictions on the use of the key should be added at the end of the file (e.g. command="git-shell" nopty no-agent-forwarding no-port-forwarding no-X11-forwarding).






          share|improve this answer












          If an account is dedicated to git usage, it makes sense for the administrator to make it a restricted account, only allowed to run git commands. In particular, git access should not be enough to change the credentials and restrictions on the account. This is done by having a ~/.ssh/authorized_keys that isn't writable by the user. There is usually an out-of-band mechanism to set up credentials, for example a web interface.



          If you're the administrator, you need to dig in to find out how the git accounts are set up. Check the SSH server configuration (/etc/sshd_config or /etc/ssh/sshd_config to see where the authorized_keys files are located (AuthorizedKeysFile setting). Once you've found the file, add the public key to it: an authorized_keys files is just a list of line, each normally containing a public key copied straight from a .pub file. Check the configuration to see whether restrictions on the use of the key should be added at the end of the file (e.g. command="git-shell" nopty no-agent-forwarding no-port-forwarding no-X11-forwarding).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 25 '17 at 23:02









          Gilles

          529k12810611587




          529k12810611587

























              0














              Let us consider we have 2 machines, 'A' and 'B'
              Now you want to connect from A to 'B'



              So in B machine do the following



              vi /etc/ssh_sshd_config



              Now search for this two line and change to the following as shown below.



              PasswordAuthentication yes



              PermitRootLogin yes



              Now Restart the sshd service in 'B' machine



              service sshd restart



              Now copy the key from 'A' machine to 'B' machine and I hope it will Work fine



              ssh-copy-id root@154.34.22.109






              share|improve this answer


























                0














                Let us consider we have 2 machines, 'A' and 'B'
                Now you want to connect from A to 'B'



                So in B machine do the following



                vi /etc/ssh_sshd_config



                Now search for this two line and change to the following as shown below.



                PasswordAuthentication yes



                PermitRootLogin yes



                Now Restart the sshd service in 'B' machine



                service sshd restart



                Now copy the key from 'A' machine to 'B' machine and I hope it will Work fine



                ssh-copy-id root@154.34.22.109






                share|improve this answer
























                  0












                  0








                  0






                  Let us consider we have 2 machines, 'A' and 'B'
                  Now you want to connect from A to 'B'



                  So in B machine do the following



                  vi /etc/ssh_sshd_config



                  Now search for this two line and change to the following as shown below.



                  PasswordAuthentication yes



                  PermitRootLogin yes



                  Now Restart the sshd service in 'B' machine



                  service sshd restart



                  Now copy the key from 'A' machine to 'B' machine and I hope it will Work fine



                  ssh-copy-id root@154.34.22.109






                  share|improve this answer












                  Let us consider we have 2 machines, 'A' and 'B'
                  Now you want to connect from A to 'B'



                  So in B machine do the following



                  vi /etc/ssh_sshd_config



                  Now search for this two line and change to the following as shown below.



                  PasswordAuthentication yes



                  PermitRootLogin yes



                  Now Restart the sshd service in 'B' machine



                  service sshd restart



                  Now copy the key from 'A' machine to 'B' machine and I hope it will Work fine



                  ssh-copy-id root@154.34.22.109







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 16 '18 at 14:07









                  imran

                  1




                  1






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • 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%2funix.stackexchange.com%2fquestions%2f373210%2fssh-copy-id-permission-denied%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

                      Entries order in /etc/network/interfaces

                      新発田市

                      Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)