2012-03-09 626 views
10

我一直在扫描网络/ SO,并阅读了多个权限被拒绝请求帮助我只是无法找到一个以我理解的方式解决我的问题。.ssh/id_rsa失败:权限被拒绝

我遵循这些说明(Getting Started with Python on Heroku/Cedar)。一切都没事,直到:

[email protected]:~/helloflask$ source venv/bin/activate 
(venv)[email protected]:~/helloflask$ git push heroku master 

The authenticity of host 'heroku.com (50.19.85.132)' can't be established. 
RSA key fingerprint is ##:##:##:##:##:##:##:##:##:##:##:## (I replaced with #) 
Are you sure you want to continue connecting (yes/no)? yes 
Failed to add the host to the list of known hosts (/home/drewverlee/.ssh/known_hosts). 
Permission denied (publickey). 
fatal: The remote end hung up unexpectedly 

(不知道安全的,所以我换成(#)键)

我想可能是因为

drwx------ 2 root  root  1024 2012-03-08 21:26 .ssh 

因为

[email protected]:~$ ssh-keygen 
Generating public/private rsa key pair. 
Enter file in which to save the key (/home/drewverlee/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
open /home/drewverlee/.ssh/id_rsa failed: Permission denied. 
Saving the key failed: /home/drewverlee/.ssh/id_rsa. 

作为一个在这些问题上经验不多的人,我不确定如何撤销我已经安全完成的任务我正在干涉强大的工具。有关这里发生了什么的任何建议? 让我知道是否需要包含更多信息来解决问题。

+0

@CIRCLE对我来说看起来不是一个好主意 – Phoenix87 2017-07-22 11:48:57

回答

34

您应该拥有自己目录中.ssh目录的权限,但在您的情况下,它拥有root权限。尝试

cd ~ 
sudo chown drewverlee .ssh 

然后重试创建密钥并连接。

+0

我想出了如何拥有我的整个用户目录,因为我读到这可能是高效的事情。感谢您指点我正确的方向。 – 2012-03-13 01:11:40

+4

我发现ssh-keygen更喜欢创建.ssh目录。如果目录已经存在,它会发出权限被拒绝的消息,而不管是否允许所有权权限配置。 – ddoxey 2013-09-12 18:47:48

4

我有同样的问题在CentOS 6除去SELinux的解决了这个问题:

sudo yum remove selinux* 

found the answer here

注:可能不是一个好主意,盲目删除SELinux的,如果你不知道你在做什么

+0

禁用selinux更容易,而不是通过更改'/ etc/selinux/config'中的'SELINUX = disabled'来删除它。参见[Cenos文档](http://www.centos.org/docs/5/html/5.2/Deployment_Guide/sec-sel-enable-disable.html) – 2013-09-02 08:20:29

+0

[停止禁用Selinx](http://stopdisablingselinux.com /)它确实是一个selinux问题,您应该通过查看审核日志来修复上下文。 – 2014-01-08 16:01:46

1

由于某些原因,〜/ .ssh文件夹中的id_rsa文件对我的用户(0400)处于只读模式。我把它改为读写(0600)与

chmod 0600 id_rsa 

后我显然能够覆盖文件。我想这些是你可以给这个文件最高的权限,因为其他人不会有太大的意义。

相关问题