2012-03-09 254 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 

後我顯然能夠覆蓋文件。我想這些是你可以給這個文件最高的權限,因爲其他人不會有太大的意義。

相關問題