uranusjr / Qelly

Beautiful cross-platform BBS client.
61 stars 14 forks source link

第一次使用 ssh 的確認訊息並未出現在 Qelly 視窗中 #47

Open lantw44 opened 11 years ago

lantw44 commented 11 years ago

第一次連線到 ssh://bbs@ptt.cc 時,Qelly 的分頁會沒有反應,而 terminal 中出現 The authenticity of host 'ptt.cc (140.112.172.2)' can't be established. ECDSA key fingerprint is 85:72:37:b1:6d:98:c8:0c:80:97:6a:9f:eb:1c:4e:3b. Are you sure you want to continue connecting (yes/no)?

也許這應該改為在連線分頁裡面出現?至少 PCManX 是這麼做的。

uranusjr commented 11 years ago

Hmm, 我測的時候 key verification 是出現在 terminal 沒錯, 不知道為什麼會有這個差異。我研究一下 ssh 的 parameters 好了,可以麻煩提供一下你的 distribution 和桌面環境嗎?

lantw44 commented 11 years ago

貼 issue 時使用的是 Arch Linux,沒有桌面環境,只使用 Openbox 視窗管理員,編譯方式與我剛上傳上去到 Arch User Repository 的 PKGBUILD 相同。https://aur.archlinux.org/packages/qelly-git/

不過我平常使用的其實是 Fedora 19,桌面環境是 GNOME 3.8,測試後也是有相同的問題,編譯方法相同。

uranusjr commented 11 years ago

Thx, will check.

lantw44 commented 11 years ago

我用 pstree -a 看到 pcmanx 其實也只有執行 ssh bbs@ptt.cc,沒有特殊參數

uranusjr commented 11 years ago

我看 Nally 是 -e none -x https://github.com/yllan/nally/blob/master/Code/YLSSH.mm

也搞不好是我 stderr 還是什麼沒接好就是了 orz

lantw44 commented 11 years ago

PCManX 好像是直接 ssh 而已 https://code.google.com/p/pcmanx-gtk2/source/browse/src/view/telnetcon.cpp#301

uranusjr commented 11 years ago

仔細研究發現 PCMan 和 Nally 都是用 forkpty, 和我的作法其實不一樣...Fingerprint prompt 其實「不是」從 SSH 生出來的, 沒辦法重導向 (例如 ssh (some_server) >/dev/null 2>&1 它還是會跑出來), 所以我沒辦法從 stdout/stderr 接到... orz

我在 elementary OS (Ubuntu-based) 上測試發現 fingerprint prompt 會用 GUI dialog 跳出來, 不過 Fedora 確實是像你講的那樣會吐給 shell。實在不想改用 forkpty 因為這樣 Windows 和 Linux 就會差很大 (雖然也是可以做), 不知道有沒有比較通用的方法。

或者就是要想辦法直接自己幹一個 SSH client 了... orz

lantw44 commented 11 years ago

我簡單的在 Fedora 上用 strace 測試了一下 (因為 terminal 是用 UTF-8 所以這裡測 bbsu@ptt.cc) strace -f -o ssh.strace ssh bbsu@ptt.cc >/dev/null 2>&1 發現並沒有 child process 產生,搜尋 openssh 6.3p1 的 code 發現那個 prompt 的文字也確實是在 ssh 裡面 不過發現一段特別的東西

3805  open("/dev/tty", O_RDWR)          = 4
(中間省略)
3805  write(4, "The authenticity of host 'ptt.cc"..., 199) = 199                 
3805  read(4, "y", 1)                   = 1                                      
3805  read(4, "e", 1)                   = 1                                      
3805  read(4, "s", 1)                   = 1                                      
3805  read(4, "\n", 1)                  = 1    

看起來是因為 ssh 怕使用者把輸入輸出重導掉,導致看不到訊息,所以 ssh 自己去把 controlling terminal 打開。似乎要把 controlling terminal 換掉才能解決這問題。

有趣的是,我把 ssh 的 controlling terminal 拿掉,也就是改執行 setsid ssh bbsu@ptt.cc,結果 ssh 居然換用 GUI dialog 來讓我打 yes 了。如果在沒有 GUI 的環境下,他會直接 Host key verification failed。

uranusjr commented 11 years ago

這倒是給我一個想法, 如果直接在 QProcess 執行 setsid 不知道會怎樣。

不過 GUI prompt 有個問題是如果沒有 askpass 也是會 verification failed, 而且這個訊息我們應該還是看不到。

替換 terminal 應該是沒有容易的解,都是要做苦工,感覺不值得。等這波 bug 修得差不多之後我直接來研究 libssh2 或其他做法好了