我对Git很新。 我的客户要求我在我的系统中安装git并告诉我传递ssh密钥(id_rsa.pub)。我转移密钥并注册,之后我们就可以下载应用程序了。
然后我们决定转向Fedora 14(Linux)。我们再次安装了git,我们再次将密钥转移到服务器中注册到客户端。但现在客户提到我们可以使用相同的密钥。
是否可以使用相同的密钥?
我尝试了以下步骤:(一旦在Fedora中安装了git。)
ssh-keygen -t rsa -C "your_email@youremail.com"
(与Windows操作系统上使用的电子邮件ID相同)git clone git@git.xyz.com:x2.git
但没有运气。
当我尝试:
git clone git@git.xyz.com:x2.git
Cloning into x2...
ssh: connect to host git.xyz.com port 22: connection timed out
fatal: The remote end hung up unexpectedly.
有人可以帮助我理解和解决这个问题吗? 锁定访问还有其他问题吗?
提前致谢。
答案 0 :(得分:5)
ssh私钥没有绑定到计算机上,您可以将其从一台计算机复制到另一台计算机,并且应该能够ssh(并因此使用git)到具有您的公钥的服务器。您不必重新创建密钥并替换副本等,但从键的角度来看,即使您所做的也很好。
您收到的错误是ssh: connect to host git.xyz.com port 22: connection timed out fatal
,这似乎暗示该框无法访问服务器。
答案 1 :(得分:2)
如上所述@manojlds,您可以复制ssh密钥。我亲自在开发机器上完成了这项工作。
连接时间似乎是由于ssh-daemon未运行。为确保您可以连接到本机,请运行以下诊断
ps -ef | grep sshd
你应该
root 726 1 0 08:07 ? 00:00:00 /usr/sbin/sshd -D
如果sshd正在运行,请仔细检查密钥的权限并强制设置为0700。
cd .ssh
chmod -R 0700 * #Read only to the user only
如果你
,请尝试运行ssh -v <user>@<host>
ssh -v 192.168.0.150
OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.0.150 [192.168.0.150] port 22.
debug1: connect to address 192.168.0.150 port 22: Connection refused
ssh: connect to host 192.168.0.150 port 22: Connection refused
然后你的sshdaemon出现了问题,因为初始握手失败了。成功的沟通如下:
OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.0.xxx [192.168.0.xxx] port 22.
debug1: Connection established.
debug1: identity file /home/xxx/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/xxx/.ssh/id_rsa-cert type -1
debug1: identity file /home/xxx/.ssh/id_dsa type -1
debug1: identity file /home/xxx/.ssh/id_dsa-cert type -1
debug1: identity file /home/xxx/.ssh/id_ecdsa type -1
debug1: identity file /home/xxx/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.6
debug1: match: OpenSSH_5.6 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-1ubuntu3
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 zz
The authenticity of host '192.168.0.xxx (192.168.0.xxx)' can't be established.
RSA key fingerprint is zzzzz.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.xxx' (RSA) to the list of known hosts.
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,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/parj/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.0.xxx ([192.168.0.xxx]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_GB.UTF-8
Last login: Wed Dec 21 16:46:48 2011
答案 2 :(得分:0)
LocalUser是Lu,RemoteUser是Ru。
Lu $ mkdir~ / .ssh
Lu $ scp usernameOfRu @ ipOfRu:.ssh / * .ssh / *
usernameOfRu @ ipOfRu的密码:“输入远程系统的密码”