[服務架設][系統][sshd] ssh_exchange_identification: Connection closed by remote host 解決

ssh_exchange_identification: Connection closed by remote host

以下討論 ssh client 連到 sshd 伺服器時遇到「ssh_exchange_identification: Connection closed by remote host」訊息的可能解決方法。

問題:

使用 ssh client 連到某台目標主機時可能會遇到以下錯誤訊息:

[aa@example ~]$ ssh -v aabbcc@1.2.3.4
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 1.2.3.4 [1.2.3.4] port 22.
debug1: Connection established.
debug1: identity file /home/aa/.ssh/identity type -1
debug1: identity file /home/aa/.ssh/identity-cert type -1
debug1: identity file /home/aa/.ssh/id_rsa type -1
debug1: identity file /home/aa/.ssh/id_rsa-cert type -1
debug1: identity file /home/aa/.ssh/id_dsa type -1
debug1: identity file /home/aa/.ssh/id_dsa-cert type -1
debug1: identity file /home/aa/.ssh/id_ecdsa type -1
debug1: identity file /home/aa/.ssh/id_ecdsa-cert type -1
ssh_exchange_identification: Connection closed by remote host
[aa@example ~]$

可能解法:

1. 可能被 hosts.allow / hosts.deny 擋了

檢查一下 /etc/hosts.deny 和 /etc/hosts.allow,用 root 權限的帳號去在 hosts.allow 中寫上「sshd: ALL」如下 :

root@example # grep sshd /etc/hosts.allow
sshd: ALL

2. 可能 sshd 所在的伺服器最近有更新 glibc 或 openssl libs

去嘗試重新跑一下 sshd,然後重試看看。

3. ~/.ssh/known_hosts

刪除 ~/.ssh/known_hosts 目標伺服器對應的那一行,然後重試看看。

4. 伺服器過於忙碌

在 sshd 伺服器端的 /etc/ssh/sshd_config 內將 MaxStartups 調大,如下:

# 舊樣式
MaxStartups 20
# 新樣式
MaxStartups 10:20:30

然後重跑 sshd。

5. 用 Snology NAS 的話,確認沒有被「自動封鎖」機制擋了

可在 Snology DSM 的 web GUI 登入後,開啟控制台應用程式,在 安全性 >> 帳號 >> 自動封鎖,找到「允許/封鎖 清單」按鈕,然後去看看有沒有被封鎖了。有的話則將想要解除封鎖的 IP 刪除即可。

6. 確認周邊的網路裝置,例如 router, switch, WiFi AP  等等的組態設定沒有去擋 ssh 連線。

除錯:

可在伺服器端用「sshd -d -p 2222」在 port 2222 跑起 debug 用的 sshd 。(不會和已經跑起的 port 22 的 sshd 衝突)

然後再用 ssh client 連連看「ssh -v -p 2222 aabbcc@1.2.3.4」,觀察看看錯誤訊息,以知道是上述的哪一種問題。

[服務架設][系統][PHP] Fatal error: Call to undefined function exif_read_data()

[服務架設][系統][PHP] Fatal error: Call to undefined function exif_read_data()

If you got a ‘Fatal error: Call to undefined function exif_read_data(): …..’ error during executing your PHP program, you may:

case1: (Using PHP in Microsoft Windows environment)

Edit your php.ini and move the ‘extension=php_mbstring.dll’ prior to ‘extension=php_exif.dll’. Re-start your web-server (apache).

case2: (Linux)

Re-compile and re-install your PHP with configuration parameters –enable-exif and –enable-mbstring (compiling both exif and mbstring statically, don’t use mbstring compiled as a DSO module).

Reference:
[1] http://uk2.php.net/exif_read_data

[SEO][服務架設] 讓 MediaWiki 使用短網址(short url)

可參考的文件:

以設定 apache web server 的 httpd.conf 為例,只要做以下設定即可:

I. 設定 httpd.conf

1. 確認 ReWrite 模組有安裝

2. 設定 httpd.conf
<Directory /home/wiki>
…..
Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?title=$1 [L,QSA]
…..
</Directory>

3. 重跑 web server

II. 設定 LocalSettings.php
在自己的 MediaWiki 的『根目錄』中的 LocalSettings.php 檔案中增加以下這行設定:
$wgArticlePath = “$wgScriptPath/$1”;


特別說明事項:

  1. 避免 MediaWiKi 的『編輯器』等相關 icon 圖路徑被 rewrite:
  2. 增加一行設定:『RewriteRule ^(images|skins|fckeditor)/ – [L]
    或增加這一行避免 rewrite 相關檔案: RewriteRule \.(php|html|gif|jpg|png|css|js)$ – [L]

  3. 避免連結站內的 URL 被 rewrite:
  4. 增加:『RewriteRule ^[^:]*\. – [L]
    增加:『RewriteRule ^[^:]*\/ – [L]

  5. 避免改成短 URL 被各家 robot 誤認為是 spam,在『根目錄』中擺上『robots.txt』檔案,內容為:
  6. User-agent: *
    Disallow: /index.php

    或者,MediaWiki 程式和虛擬的文件目錄是分開時(例如: MediaWiki 程式是在 /mediawiki/ 目錄,虛擬的文件目錄是在 /wiki/), robots.txt 內容可以為:
    User-agent: *
    Disallow: /mediawiki

  7. 無法動到 httpd.conf 的話,可以在『自家』的 .htaccess 檔案中設定,詳情請參考上述的[1]。
  8. 有人可能避免用 ReWrite 而影響伺服器的效能因此改用以下方法(僅是範例):
  9. 1. 在網頁的『根目錄』中
    ln -s mediawiki/index.php ./wiki

    2. 在 httpd.conf 或 .htaccess 中
    AddHandler dh-php /cgi-system/php5.cgi
    <Files “wiki”>
    SetHandler dh-php
    </Files>


網路上有名的維基百科(Wikipedia, 維基百科中文版)就是用 MediaWiki 程式架設出來的。或是說,MediaWiki 原來是為了 Wikipedia 而寫的,它目前是個『自由軟體套件(GPL Licence)』。

除了維基百科的一些姊妹計畫站外,網路上有一大堆用 MediaWiki 套件架設出來的網站。諸彼特網站目錄也計畫要用 MediaWiki 套件為基礎去設計一套運作機制,讓網站的擁有者可以在諸彼特網站目錄中編輯自己的網站資訊,並可以為自己的資料頁面上鎖/解鎖。

維基姊妹計畫:
維基詞典
維基教科書
維基語錄
維基共享資源
維基新聞
維基文庫
維基物種
元維基

如何移除並取消 MySQL 的 binary log 檔案

o MySQL 的 binary log 檔案佔了磁碟很多的空間

在例如 /var/lib/mysql/ 目錄可能會發現不少 MySQL 的 binary log 檔案:
-rw-rw—- 1 mysql mysql 29662 Aug 6 23:53 mysql-bin.000001
-rw-rw—- 1 mysql mysql 1055243 Aug 6 23:53 mysql-bin.000002
-rw-rw—- 1 mysql mysql 1073790447 Aug 7 00:42 mysql-bin.000003
-rw-rw—- 1 mysql mysql 1074547174 Aug 7 01:30 mysql-bin.000004
-rw-rw—- 1 mysql mysql 1074351847 Aug 7 01:54 mysql-bin.000005
-rw-rw—- 1 mysql mysql 1074535688 Aug 7 02:01 mysql-bin.000006
-rw-rw—- 1 mysql mysql 1074495922 Aug 7 02:07 mysql-bin.000007
-rw-rw—- 1 mysql mysql 1074497579 Aug 7 02:13 mysql-bin.000008
-rw-rw—- 1 mysql mysql 147849819 Aug 7 17:21 mysql-bin.000009

這些檔案可以佔住了磁碟很多的空間。

這一篇要說明如何正規方式移除這些檔案,並改寫 my.cnf 設定組態不去記錄這些二進位日誌檔案。 Continue reading “如何移除並取消 MySQL 的 binary log 檔案”

安裝Google Applicaiton Engine(GAE)開發環境

Install the development environment of Google Applicaiton Engine (GAE)

1. Install Python
2. Install GoogleAppEngine-1.5.4.msi (Download from http://code.google.com/intl/zh-TW/appengine/downloads.html)
3. Install eclipse for java Developer (maybe install the jre-7-windows-x64.exe)
4. Run eclipse.exe Continue reading “安裝Google Applicaiton Engine(GAE)開發環境”

非同步載入執行JavaScript的寫法

說明:
網頁 HTML 內的 JavaScript (JS) 程式碼改寫成「非同步載入並執行」(asynchronized JavaScript)後可讓原本 HTML 頁面呈現的時間變快、而不去卡住原本主頁面的渲染時間。
這一篇將簡短說明如何將(網頁內)以下這段同步載入並執行的 JavaScript 碼範例改寫成非同步載入並執行的方式運作: Continue reading “非同步載入執行JavaScript的寫法”