我正在嘗試使用 SSH 模式來設定 GIT。中央 GIT 儲存庫位於執行 Windows 2008 伺服器的 NAS 裝置上,使用者 GIT 儲存庫位於 ubuntu 12.04 上。
然而,當我嘗試透過 SSH 連接到 Windows 電腦時,我無法成功進入。
SSH 金鑰尚未設置,但我認為問題甚至在此之前,因為我無法僅透過提供正確的密碼進入。 SSH 命令的輸出如下。
dba@clpserv01:~$ ssh -v -l administrator clpnas
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to clpnas [***.***.***.***] port 22.
debug1: Connection established.
debug1: identity file /home/dba/.ssh/id_rsa type -1
debug1: identity file /home/dba/.ssh/id_rsa-cert type -1
debug1: identity file /home/dba/.ssh/id_dsa type -1
debug1: identity file /home/dba/.ssh/id_dsa-cert type -1
debug1: identity file /home/dba/.ssh/id_ecdsa type -1
debug1: identity file /home/dba/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze2
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA bd:37:d1:98:51:2a:d6:b5:f5:c7:98:d8:74:2c:4e:cd
debug1: Host 'clpnas' is known and matches the RSA host key.
debug1: Found key in /home/dba/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /home/dba/.ssh/id_rsa
debug1: Trying private key: /home/dba/.ssh/id_dsa
debug1: Trying private key: /home/dba/.ssh/id_ecdsa
debug1: Next authentication method: keyboard-interactive
Password:
debug1: Authentications that can continue: publickey,password,keyboard-interactive
Password:
答案1
首先要做的是檢查您對主資料夾的權限。
從 *nix 命令列執行以下命令:
1)導航到您的主目錄:
cd ~
2)檢查主目錄的權限:
ls -dl
(if that doesn't work, try sudo -dl)
結果應類似以下內容:
drw------- 10 shaheed shaheed 4096 Nov 20 09:44 .
第二到第四個字元表示使用者的權限,在本例中應該是rw-
, 或讀/寫。 筆記: 如果它說rwx
相反,那就是問題所在。出於安全考慮,ssh 不希望主目錄具有寫入權限。
我的猜測是您的內容類似於以下內容:
drwx------ 10 shaheed shaheed 4096 Nov 20 09:44 .
第四位的字母x表示該使用者對該目錄有執行權限。這是禁忌。
若要解決這種情況,請使用下列命令刪除執行權限:
chmod 600 .
然後執行以下命令來驗證權限是否已正確設定:
ls -dl
您應該收到以下訊息:
ls: cannot access .: Permission denied
表明你不再具有執行權限,這是一件好事。
下次運行:
sudo ls -dl
你將能夠驗證一切都是愛!結果應該類似:
drw------- 10 shaheed shaheed 4096 Nov 20 09:44 .
現在您應該能夠進行 ssh 操作,而不會提示您輸入 git 使用者密碼。