我們偶爾會遇到一些比較奇特的問題,比方說於ssh的登入。
就會有站長反應,有時能登,有時又不能登 (換一套設備又正常)。
像這種情況下:
1.除了查看相關log檔或是 firewal deny ips。
2.還可以過linux shell語法: netstat -ap | grep ssh
看看 ssh 有沒有正常運作。
如果發現異常,就得調整一些應用程式的細部設定,
若沒問題,那就可以先排除是server端的狀況,
改去查看一下client的應用程式或是上網設備。
(本篇教學由unethost.com客服撰寫)
延伸閱讀:如何備份Cpanel後台安裝的套裝程式?
安裝上述的軟體,我們提供虛擬主機試用,七天滿意保證,
功能完整使用不受限制,歡迎點我申請。
]]>
請在 ssh shell 裡:
vim test.sh
test.sh 的內容如下:
[code language=”bash”]
#!/bin/bash
echo test begin.
env x='() { :;}; echo vulnerable’ bash -c ‘echo test done.'[/code]
關於Unix /Linux 的Bash Shell的漏洞問題,
原文出處: http://www.ithome.com.tw/news/91107
這邊就不在累敘,下列是相關OS的解法:
1. RHEL Clone (centos):
yum -y update 或是 yum -y update bash
2. Debian Clone
apt-get upgrade bash
更新完成後,bash的安全性就會得到補強。
(unethost.com虛擬主機,以於第一時間完成修正)
進階檢測請接續閱讀 : 如何檢測 Unix /Linux 的 Bash Shell 漏洞
]]>請參考我們下列說明:
1. 下載登入ssh的程式。請瀏覽網頁: http://ntu.csie.org/~piaip/pietty/
3. 輸入您所使用的主機的IP (或是網域),port為: 15678,輸入後,請點下連線。
4. 請先輸入空間的帳號在點下鍵盤ENTER鍵後,
在輸入密碼,並在點下鑑盤Enter鍵,輸入正確就會登入。
(帳號和密碼,可以用複製,貼上則是用滑鼠右鍵,而非平常使用的Ctrl-v功能)
6. 通常檔案都是在 public_html底下,所以請輸入 cd public_html ,在ENTER 。
7. 請接著輸入 下列指令: du -sh * (輸入後,請記得要ENTER) ,這時就會秀出public_html 底下的資料夾及檔案使用的容量大小。
8. 根據圖片發現 data 佔了 3.3G 容量,這時在使用 cd data切到 data資料夾底下後,
在輸入一次 du -sh * ,這樣就可以逐步追查出,是什麼地方在消耗使用容量。
最後補充: 當您登入後,只顯示出下列字串:
Shell access is not enabled on your account!
If you need shell access please contact support.
這是因為權限問題,有些帳號預設是沒有開啟SSH的,將導致無法使用SSH,
這時請透過服務單連絡我們處理,我們就會去設定開啟。
/home/A/public_html/share
/home/B/public_html/share
這兩個資料夾,是指到同一個位置。
本來我以為,只要用ln -s來建softlink,就可以把問題解決了。結果卻失敗了,softlink所在的那個帳戶,用ftp登入後,看不到share這個資料夾。這是為什麼呢?原因是在這邊,它寫說,symbolic link只能指向「正確的」的地方。使用者的ftp帳戶基本上是一個被chroot的環境,所以當然不能去看到別的使用者的檔案。
A symbolic link is a pointer to the “right” file. But if that original file is outside the jail then you can’t access it. This is the goal of a jail. Otherwise a normal user could create a symbolic link in the jail to/etc/passwd
and just read it. What a security risk!
So jailed is jailed. Probably a hard link will do the job, as this is a “copy without duplicating the used size”. And for the FTP server it is like a normal file (with all the problems).
那麼,這樣的問題該如何處理呢?用 mount –bind來處理吧。這個是正確的作法。
mkdir /home/website/files/
mount –bind /home/shared/files /home/website/files/
像這樣子的作法,shared這個使用者ftp登入後,就看得到 website這個使用者的資料夾files了。因為 /home/shared/files 和 /home/website/files是同一個資料夾。
]]>(*) example 1:
top – 01:49:59 up 49 min, 5 users, load average: 18.02, 32.55, 34.91
Tasks: 269 total, 1 running, 268 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.4%us, 0.6%sy, 0.0%ni, 16.7%id, 82.2%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 8028612k total, 2268460k used, 5760152k free, 88348k buffers
Swap: 4192924k total, 731688k used, 3461236k free, 309828k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8842 mysql 11 -10 1274m 178m 4076 S 0.0 2.3 0:46.40 mysqld
機器跑得很不順 ( 因為load已經上來了,居然有到18 )
發現 Cpu 82.2%wa —> I/O wait
—-> 因為io busy的process通常也是cpu busy,所以直接看第一行。
—-> 八成是第一行的process把cpu cycle 吃太多了
—-> 第一行就是 mysqld
喔,這個很正常,mysqld只要config不對,就容易有這種問題。
到mysql去找問題吧。
(*) example 2:
01:15:52 up 15 min, 4 users, load average: 28.37, 20.02, 10.44
Tasks: 762 total, 1 running, 760 sleeping, 0 stopped, 1 zombie
Cpu(s): 0.5%us, 1.8%sy, 0.0%ni, 0.0%id, 97.3%wa, 0.0%hi, 0.4%si, 0.0%st
Mem: 8028612k total, 7981536k used, 47076k free, 34512k buffers
Swap: 4192924k total, 2894460k used, 1298464k free, 272708k cached
機器跑得很不順 ( 因為load已經上來了,居然有到28 )
發現 Cpu 97.3%wa —> I/O wait
此外,還發現一件事: swap 被用掉了3G,mem幾乎被用光了
—-> 八成是有一隻process把ram吃光光了,是誰呢?
—-> 按shift +m
—-> 第一行就是吃最多ram的process
(*) example 3:
top – 01:27:59 up 31 days, 22:31, 3 users, load average: 2.36, 2.33, 4.96
Tasks: 697 total, 1 running, 692 sleeping, 0 stopped, 4 zombie
Cpu(s): 2.1%us, 1.2%sy, 0.0%ni, 50.9%id, 45.5%wa, 0.1%hi, 0.1%si, 0.0%st
Mem: 4023964k total, 3917884k used, 106080k free, 298548k buffers
Swap: 8385920k total, 504136k used, 7881784k free, 1557260k cached
機器的load沒有衝高,然而,io wait 還是不低 45.5% 。swap雖然有被用到了,但是還小於0.5G,小事啦…,mem也還剩不少 ( 不是ram的問題 )
雖然cpu busy的process 通常也是io busy,但是,目前這種情況無法直接確定
所以top的第一行,cpu用最多的process,就一定是io用最多的。
所以這種時候,會需要另一隻程式 iotop,直接殺向io bound的process,找出效能瓶頸。
]]>