2011-12-21 161 views
4

我對Git非常陌生。 我的客戶要求我在我的系統中安裝git,並告訴我要通過ssh密鑰(id_rsa.pub)。我轉移了密鑰並註冊了,之後我們才能夠下載該應用程序。是否可以將Git SSHKey從一個系統轉移到另一個系統

然後我們決定轉到Fedora 14(Linux)。我們再次安裝了git,然後我們再次將密鑰傳輸到服務器中註冊到客戶端。但現在客戶提到我們可以使用相同的密鑰。

是否可以使用相同的密鑰?

我嘗試下面的步驟:(一旦混帳得到安裝在Fedora中。)

  1. ssh-keygen -t rsa -C "[email protected]"(相同的電子郵件ID用作Windows操作系統)
  2. 替換所有的副本創建的3個文件3個文件(id_rsa,id_rsa.pub和known_hosts中從Windows安裝更早)
  3. 試圖git clone [email protected]:x2.git

,但沒有運氣。

當我嘗試:

git clone [email protected]:x2.git 
Cloning into x2... 
ssh: connect to host git.xyz.com port 22: connection timed out 
fatal: The remote end hung up unexpectedly. 

有人可以幫助我瞭解和解決這個問題? 是否有其他問題鎖定訪問?

在此先感謝。

+1

做'telnet git.xyz.com 22'工作? – 2011-12-21 09:10:57

+0

nope連接超時..是否有阻塞? – Rakesh 2011-12-21 09:14:42

+0

做相同的命令工作,如果你在服務器本身發出它? – 2011-12-21 09:16:52

回答

5

ssh私鑰沒有綁定到一臺機器,你可以將它從一臺機器複製到另一臺機器上,並且應該能夠將ssh(並因此使用git)發送到擁有公鑰的服務器。您不必重新創建密鑰並替換副本等,但即使從鍵盤的角度來看,您所做的一切都很好。

你得到的錯誤是ssh: connect to host git.xyz.com port 22: connection timed out fatal這似乎暗示該框無法訪問服務器。

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 [email protected] 
debug1: Entering interactive session. 
debug1: Sending environment. 
debug1: Sending env LANG = en_GB.UTF-8 
Last login: Wed Dec 21 16:46:48 2011 
0

LocalUser是Lu,而RemoteUser是Ru。

魯$的mkdir的〜/ .ssh

魯$ SCP usernameOfRu @ ipOfRu:的.ssh/*的.ssh/*

usernameOfRu @ ipOfRu的密碼: 「輸入遠程系統的密碼」

相關問題