我正在尝试使用 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 .
第 2 到第 4 个字符表示用户的权限,在本例中应该是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 用户密码。