2012-09-26 160 views
6

我在使用TortoiseSVN 1.7.8訪問SVN存儲庫時遇到問題。TortiseSVN svn + ssh錯誤:無法連接到URL中的存儲庫...網絡連接意外關閉

SVN存儲庫位於CentOS 6.3盒子上,其中openssh 5.3p1:81.el6似乎運行正常。

# svnadmin --version 
# svnadmin, version 1.6.11 (r934486) 

我可以從另一個CentOS的盒子用這個命令訪問知識庫:

svn list svn+ssh://[email protected]/var/svn/joetest 

但是,當我試圖從一個Win 7的工作站,我不能這樣做瀏覽使用TortiseSVN的倉庫,所以使用以下路徑:

svn+ssh://[email protected]/var/svn/joetest 

我收到以下錯誤在TortoiseSVN:

Unable to connect to a repository at URL 'svn+ssh://[email protected]/var/svn/joetest' To better debug SSH connection problems, remove the -q option from 'ssh' in the [tunnels] section of your Subversion configuration file. Network connection closed unexpectedly

我可以使用Putty通過SSH從工作站登錄。

如果我以root身份嘗試訪問,結果是一樣的。

我給庫/var/svn/的所有權USER:USER
chmod 2700 -R /var/svn/

因爲我可以通過ssh從另一個Linux機器訪問存儲庫,所以權限似乎不成問題。

當我看使用tail -fn 2000 /var/log/secure日誌文件,我每次看到TortiseSVN要求輸入密碼以下內容:

Sep 26 17:34:31 dev sshd[30361]: Accepted password for USER from xx.xxx.xx.xxx port 59101 ssh2 
Sep 26 17:34:31 dev sshd[30361]: pam_unix(sshd:session): session opened for user USER by (uid=0) 
Sep 26 17:34:31 dev sshd[30361]: pam_unix(sshd:session): session closed for user USER 

實際上,我能夠登錄,但會話,然後立即關閉。

它引起了我的注意,會話正在以USER (uid=0)的身份打開,這可能是正確的,但如果它與問題有關,我會提及它。

我調查了修改svnserve.conf,但據我所知,通過svn+ssh訪問存儲庫時未使用,通過此方法爲每個日誌創建私有svnserve實例。從手冊:

There's still a third way to invoke svnserve, and that's in 「tunnel mode」, with the -t option. This mode assumes that a remote-service program such as RSH or SSH has successfully authenticated a user and is now invoking a private svnserve process as that user. The svnserve program behaves normally (communicating via stdin and stdout), and assumes that the traffic is being automatically redirected over some sort of tunnel back to the client. When svnserve is invoked by a tunnel agent like this, be sure that the authenticated user has full read and write access to the repository database files. (See Servers and Permissions: A Word of Warning.) It's essentially the same as a local user accessing the repository via file:/// URLs.

唯一的非默認設置在sshd_config是:

Protocol 2 # to disable Protocol 1 

SyslogFacility AUTHPRIV 

ChallengeResponseAuthentication no 

GSSAPIAuthentication yes 
GSSAPICleanupCredentials yes 

UsePAM yes 

AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES 
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT 
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE 
AcceptEnv XMODIFIERS 

X11Forwarding no 

Subsystem  sftp /usr/libexec/openssh/sftp-server 

有什麼想法?

+0

只是一個想法,嘗試從URL中取出USER @並等待烏龜提示輸入憑證。不知道它是否會起作用,但值得一試。 – Scott

+0

感謝您的建議,但結果相同。 – codewaggle

+0

當你打開烏龜回購瀏覽器時,它給你什麼錯誤? – Scott

回答

4

我終於遇到了這個解決方案。在所有的地方TortoiseSVN的常見問題解答:
TortoiseSVN Frequently asked questions

從常見問題:
SVN+SSH: Connection closed unexpectedly

It has been reported that svn+ssh connections of the form svn+ssh://[email protected] which were previously working, stop working with TortoiseSVN 1.5. This seems to be related to plink, and occurs if you have a default hostname set in PuTTY.

If this is the case you can fix it by using regedit or regedt32 to clear HKEY_CURRENT_USER/Software/SimonTatham/Putty/Sessions/Default%20Settings/HostName.


Another user has reported the following server-side fix:

  • ssh into your account
  • cd ~
  • cp /etc/bashrc .bashrc
  • nano .bashrc
  • put a # before the line "mesg y" (which comments it out)
  • Ctrl+X to exit, press Y when prompted to save.

我沒有嘗試編輯我的註冊表的第一種方法。

第二種編輯bash配置的方法適用於我。

有關bash的配置方法的說明:

如果你在共享主機,你的用戶.bashrc文件可能會被載入全局的/ etc/.bashrc的文件。您將無法編輯全局文件,因此您需要解決該問題。

一些可能的方案:

  • 嘗試增加mesg n到您的用戶.bashrc文件。我不確定這個 是否可以正常工作,或者是否應該在全局文件加載前 之前或之後放置。

  • 不要在您的 用戶.bashrc文件中包含全局文件和硬編碼中的所有設置。

  • 從全局/ etc/bashrc文件中刪除mesg y設置,因爲它的加載是 。這個問題討論如何做到這一點:Use a grepped file as an included source in bash

+0

我正在嘗試做同樣的事情,我收到了上面發佈的相同錯誤消息。但是,我可以通過使用gui和使用svn + ssh:// user @ ip/repo瀏覽它來連接到我的repo,但它不會允許我通過命令行執行此操作。你有沒有運氣使用命令行做這件事? –

+0

@nkon這是一個小項目,我不再訪問該服務器,所以我無法測試它。我建議你打開一個問題,並提供所有關於這些命令的詳細信息,並且不能與SVN,SSH和BASH的日誌條目和配置一起工作(類似於我在問答中所包含的內容)。這將給有人看到可能導致問題的最佳機會。創建問題後在此處添加註釋,然後我會查看它。 – codewaggle

2

一個老問題,但仍對谷歌堆棧的頂部,所以我想我會分享我的解決方案。

簡而言之,這是因爲我沒有在服務器上爲我的用戶設置「主目錄」。將SSH客戶端更改爲Putty附帶的plink.exe(右鍵單擊文件夾| TortoiseSVN | Settings | Network)可以讓我在窗口出現在屏幕上時看到錯誤。

0

在我的情況下,原因是,svnuser沒有shell(它是/ bin/false)。
即使使用調試ssh -vvv,這在ssh日誌中也不可見。

當你有這種類型的問題,您的調試輸出將看起來像這樣

debug1: Entering interactive session. 
debug1: Remote: Forced command. 
debug1: Remote: Port forwarding disabled. 
debug1: Remote: Agent forwarding disabled. 
debug1: Remote: X11 forwarding disabled. 
debug1: Remote: Pty allocation disabled. 
debug1: Remote: Forced command. 
debug1: Remote: Port forwarding disabled. 
debug1: Remote: Agent forwarding disabled. 
debug1: Remote: X11 forwarding disabled. 
debug1: Remote: Pty allocation disabled. 
debug1: Sending environment. 
debug1: Sending env LANG = en_GB.UTF-8 
debug1: Sending command: svnserve -t 
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0 
debug1: channel 0: free: client-session, nchannels 1 

當shell設置爲/ bin/bash的日誌變爲

debug1: Sending env LANG = en_GB.UTF-8 
debug1: Sending command: svnserve -t 
Path: MyRepo 
URL: svn+ssh://[email protected]/MyRepo 
相關問題