2017-09-14 52 views
1

刪除公共密鑰文件的錯誤,我只是用官方視護目鏡/視護目鏡-RPI碼頭工人的形象,這是我跑as suggested安裝Gogs (Go Git Server)上覆盆子PI3:視護目鏡拋出一個「Permission denied」當我從客戶端

docker run --name=gogs -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs-rpi 

我用筆記本電腦通過gogs web界面註冊了一個管理員用戶,併爲該帳戶添加了一個公鑰。我現在可以使用此命令克隆從PI git倉庫到我的筆記本電腦:

git clone ssh://[email protected]:10022/peter/my_repo.git 

我進入關鍵短語,它工作得很好。

現在奇怪的部分...當我從我的筆記本電腦中刪除公鑰文件(id_rsa_gogs.pub)並再次運行上述命令時,我會得到一個'訪問被拒絕'的錯誤。

有誰知道這可能是什麼?我已經在Gogs註冊了公鑰。爲什麼我需要在客戶端計算機上有公鑰密鑰的版本?我從來沒有聽說過公鑰需要留在客戶端的情況。

Udapte

如果我的RM的.pub密鑰文件並運行ssh -Tv [email protected] -p 10022 -i /home/peter/.ssh/id_rsa_gogs我得到這個:

OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g 1 Mar 2016 
debug1: Reading configuration data /home/peter/.ssh/config 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: /etc/ssh/ssh_config line 19: Applying options for * 
debug1: Connecting to 192.168.178.50 [192.168.178.50] port 10022. 
debug1: Connection established. 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/peter/.ssh/id_rsa_gogs type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/peter/.ssh/id_rsa_gogs-cert type -1 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4 
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000 
debug1: Authenticating to 192.168.178.50:10022 as 'git' 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug1: kex: algorithm: [email protected] 
debug1: kex: host key algorithm: ecdsa-sha2-nistp256 
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none 
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none 
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY 
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:[REMOVED] 
debug1: Host '[192.168.178.50]:10022' is known and matches the ECDSA host key. 
debug1: Found key in /home/peter/.ssh/known_hosts:18 
debug1: rekey after [REMOVED] blocks 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug1: rekey after [REMOVED] blocks 
debug1: SSH2_MSG_NEWKEYS received 
debug1: SSH2_MSG_EXT_INFO received 
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521> 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug1: Authentications that can continue: publickey,keyboard-interactive 
debug1: Next authentication method: publickey 
debug1: Trying private key: /home/peter/.ssh/id_rsa_gogs 
Enter passphrase for key '/home/peter/.ssh/id_rsa_gogs': 
debug1: Authentication succeeded (publickey). 
Authenticated to 192.168.178.50 ([192.168.178.50]:10022). 
debug1: channel 0: new [client-session] 
debug1: Requesting [email protected] 
debug1: Entering interactive session. 
debug1: pledge: network 
debug1: client_input_global_request: rtype [email protected] want_reply 0 
debug1: Remote: Forced command. 
debug1: Remote: Port forwarding disabled. 
debug1: Remote: X11 forwarding disabled. 
debug1: Remote: Agent forwarding disabled. 
debug1: Remote: PTY allocation disabled. 
debug1: Sending environment. 
debug1: Sending env LC_TELEPHONE = de_DE.UTF-8 
debug1: Sending env LANG = en_US.UTF-8 
debug1: Sending env LC_NAME = de_DE.UTF-8 
debug1: Sending env LC_MEASUREMENT = de_DE.UTF-8 
debug1: Sending env LC_IDENTIFICATION = de_DE.UTF-8 
debug1: Sending env LC_MONETARY = de_DE.UTF-8 
debug1: Sending env LC_PAPER = de_DE.UTF-8 
debug1: Sending env LC_ADDRESS = de_DE.UTF-8 
debug1: Sending env LC_NUMERIC = de_DE.UTF-8 
Hi there, You've successfully authenticated, but Gogs does not provide shell access. 
If this is unexpected, please log in with password and setup Gogs under another user. 
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0 
debug1: channel 0: free: client-session, nchannels 1 
Transferred: sent 3268, received 3096 bytes, in 0.2 seconds 
Bytes per second: sent 15416.0, received 14604.6 
debug1: Exit status 0 

看來,如果我跑ssh -Tv [email protected] -p 10022失敗(不直接指定密鑰文件):

OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g 1 Mar 2016 
debug1: Reading configuration data /home/peter/.ssh/config 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: /etc/ssh/ssh_config line 19: Applying options for * 
debug1: Connecting to 192.168.178.50 [192.168.178.50] port 10022. 
debug1: Connection established. 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/peter/.ssh/id_rsa type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/peter/.ssh/id_rsa-cert type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/peter/.ssh/id_dsa type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/peter/.ssh/id_dsa-cert type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/peter/.ssh/id_ecdsa type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/peter/.ssh/id_ecdsa-cert type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/peter/.ssh/id_ed25519 type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/peter/.ssh/id_ed25519-cert type -1 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4 
debug1: match: OpenSSH_7.4 pat OpenSSH* compat [REMOVED] 
debug1: Authenticating to 192.168.178.50:10022 as 'git' 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug1: kex: algorithm: [email protected] 
debug1: kex: host key algorithm: ecdsa-sha2-nistp256 
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none 
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none 
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY 
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:[REMOVED] 
debug1: Host '[192.168.178.50]:10022' is known and matches the ECDSA host key. 
debug1: Found key in /home/peter/.ssh/known_hosts:[REMOVED] 
debug1: rekey after [REMOVED] blocks 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug1: rekey after [REMOVED] blocks 
debug1: SSH2_MSG_NEWKEYS received 
debug1: SSH2_MSG_EXT_INFO received 
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521> 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug1: Authentications that can continue: publickey,keyboard-interactive 
debug1: Next authentication method: publickey 
debug1: Trying private key: /home/peter/.ssh/id_rsa 
debug1: Trying private key: /home/peter/.ssh/id_dsa 
debug1: Trying private key: /home/peter/.ssh/id_ecdsa 
debug1: Trying private key: /home/peter/.ssh/id_ed25519 
debug1: Next authentication method: keyboard-interactive 
debug1: Authentications that can continue: publickey,keyboard-interactive 
debug1: No more authentication methods to try. 
Permission denied (publickey,keyboard-interactive). 

檢查是否同樣的問題出現wh註冊並使用沒有任何密碼的ssh密鑰。

結果是一樣的,沒有密碼。

我不知道它的問題,但我有這裏面~/.ssh/config視護目鏡

Host 192.168.178.50:10022 
    HostName 192.168.178.50:10022 
    IdentityFile ~/.ssh/id_rsa_gogs 
    User Peter 

回答

2
Host 192.168.178.50:10022 
    HostName 192.168.178.50:10022 
    IdentityFile ~/.ssh/id_rsa_gogs 
    User Peter 

ssh不接受端口號的任一HostHostname此選項的一部分。因此,它不承認此條目應該適用於您的連接嘗試,並且不會應用身份文件或用戶。

如果你只需要相匹配的IP地址,這應該工作:

Host 192.168.178.50 
    Port 10022 
    IdentityFile ~/.ssh/id_rsa_gogs 
    User Peter 

如果你真的需要相匹配的端口上,這應該工作:

Match host 192.168.178.50 exec "test %p = 10022" 
    IdentityFile ~/.ssh/id_rsa_gogs 
    User Peter 

這將運行test命令來測試端口值。 「%p」將被ssh在該點使用的端口值替換(缺省值爲22或命令行中的值)。測試也被稱爲[;它是一個命令行工具,主要用在shell腳本中作爲if語句的一部分。

1

,以瞭解什麼是真正導致錯誤嘗試的ssh -Tv [email protected] -p 10022 -i /home/peter/.ssh/id_rsa_gogs

檢查是否在註冊和使用ssh密鑰時看到相同問題沒有任何密碼短語。 (即使public keys don't have the passphrase

+0

感謝您的回答!我已經更新了這個問題。 – Rotareti

+0

@Rotareti嘗試重命名你的'/ home/peter/.ssh/config',看看是否選擇了默認的id_rsa鍵。 – VonC

+0

'mv config back_config'後情況保持不變。只有'ssh -Tv'輸出後才顯示第2行和第3行。 – Rotareti

相關問題