ssh-copy-id permission denied
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
add a comment |
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
Can you check permission of.sshdirectory usingls -ld .sshin the git server? The user and group ownership should begit:gitand permission should be700
– 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 totouch .ssh/authorized_keyson the server?
– l0b0
Jun 25 '17 at 9:48
git@rs000018:~$ touch .ssh/authorized_keystouch: cannot touch ‘.ssh/authorized_keys’: Permission deniedSeems 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
add a comment |
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
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
ssh
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.sshdirectory usingls -ld .sshin the git server? The user and group ownership should begit:gitand permission should be700
– 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 totouch .ssh/authorized_keyson the server?
– l0b0
Jun 25 '17 at 9:48
git@rs000018:~$ touch .ssh/authorized_keystouch: cannot touch ‘.ssh/authorized_keys’: Permission deniedSeems 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
add a comment |
Can you check permission of.sshdirectory usingls -ld .sshin the git server? The user and group ownership should begit:gitand permission should be700
– 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 totouch .ssh/authorized_keyson the server?
– l0b0
Jun 25 '17 at 9:48
git@rs000018:~$ touch .ssh/authorized_keystouch: cannot touch ‘.ssh/authorized_keys’: Permission deniedSeems 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
add a comment |
2 Answers
2
active
oldest
votes
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).
add a comment |
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
add a comment |
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
});
}
});
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%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
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).
add a comment |
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).
add a comment |
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).
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).
answered Jun 25 '17 at 23:02
Gilles
529k12810611587
529k12810611587
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Nov 16 '18 at 14:07
imran
1
1
add a comment |
add a comment |
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.
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%2funix.stackexchange.com%2fquestions%2f373210%2fssh-copy-id-permission-denied%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
Can you check permission of
.sshdirectory usingls -ld .sshin the git server? The user and group ownership should begit:gitand permission should be700– 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_keyson the server?– l0b0
Jun 25 '17 at 9:48
git@rs000018:~$ touch .ssh/authorized_keystouch: cannot touch ‘.ssh/authorized_keys’: Permission deniedSeems 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