Linux 向authorized_keys添加SSH密钥:权限被拒绝(公钥)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17821269/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding SSH Key to authorized_keys: permission denied(publickey)
提问by JREAM
- I have an
id_rsa
andid_rsa.pub
on my computer also tied into my BitBucket account. - As I understand I can use this public key anywhere I please (as long as my private matches).
- 我的计算机上有一个
id_rsa
和id_rsa.pub
也绑定到我的 BitBucket 帐户。 - 据我所知,我可以在任何地方使用这个公钥(只要我的私人匹配)。
The Problem: I cannot figure out how to get any server to accept the public key, do you see what I've done wrong?
问题:我不知道如何让任何服务器接受公钥,你看到我做错了什么吗?
$ cat id_rsa.pub >> authorized_keys
$ service ssh restart (I suppose this isn't needed)
$ git pull origin master
$ Permission denied(publickey)
What am I doing wrong? I've been stuck for days.
我究竟做错了什么?我已经被困了好几天了。
采纳答案by exussum
You need to copy the content of id_rsa.pub to the bitbucket avcount its in the settings page
您需要将 id_rsa.pub 的内容复制到设置页面中的 bitbucket avcount
For more info https://confluence.atlassian.com/display/BITBUCKET/How+to+install+a+public+key+on+your+Bitbucket+account
回答by Jonathan Wakely
Make sure the permissions on ~/.ssh
are 700
i.e. only accessible by the owner, and the permissions on the public and private key files are not writable except by the owner.
确保上的权限~/.ssh
是700
即只能由拥有者访问,并在公共和私有密钥文件的权限都没有,除了由业主可写。
Make sure the key files are in ~/.ssh
!
确保密钥文件在~/.ssh
!
Make sure the key is being used (try ssh'ing to the right user @ the bitbucket server using ssh -v
)
确保正在使用密钥(尝试使用 ssh 连接到正确的用户@bitbucket 服务器ssh -v
)
回答by zachaysan
If you copied your root's authorized_keys
you may have to do more than you are used to:
如果你复制了你的根目录,authorized_keys
你可能需要做的比你习惯的更多:
chmod 700 .ssh
sudo chmod 640 .ssh/authorized_keys
sudo chown $USER .ssh
sudo chown $USER .ssh/authorized_keys
Where $USER
is your linux username.
$USER
你的linux用户名在哪里。