在mac OSx上设置ssh

时间:2015-04-16 10:30:17

标签: macos git ssh

我正在尝试在我的本地mac机器上设置一个git服务器。 我按照link中提到的步骤进行操作。

但不知怎的,即使我能够ping机器,当我尝试使用ssh git@ip_address.com连接到机器时,它会出错 - “权限被拒绝(公钥)”

无法找到此错误的答案。 如果有人遇到问题并有解决方案,请告诉我。 提前谢谢。

我的命令行数据:

Kaustubhs-Pro:~ kaustubh$ ssh git@192.168.43.115 -v
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to 192.168.43.115 [192.168.43.115] port 22.
debug1: Connection established.
debug1: identity file /Users/kaustubh/.ssh/id_rsa type 1
debug1: identity file /Users/kaustubh/.ssh/id_rsa-cert type -1
debug1: identity file /Users/kaustubh/.ssh/id_dsa type -1
debug1: identity file /Users/kaustubh/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com 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 
b2:59:8a:cc:f8:1a:76:8f:2a:6f:f5:a1:2b:f1:ff:10
debug1: Host '192.168.43.115' is known and matches the RSA host key.
debug1: Found key in /Users/kaustubh/.ssh/known_hosts:3
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
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/kaustubh/.ssh/my_git_key
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /Users/kaustubh/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/kaustubh/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).

1 个答案:

答案 0 :(得分:1)

您的实际用户 kaustubh 中没有可用于SSH身份验证的有效密钥。因此,请将您的公钥添加到GIT用户的authorized_keys

所以你可以使用

ssh-copy-id git@192.168.43.115

将实际公钥添加到git授权密钥。您必须首次使用用户名和密码登录。