Browsing articles in "裝機紀錄"
根據 Heartbleed Bug 的揭露,OpenSSL發生了一個嚴重的資安問題。受到影響的Linux有下列幾項
- Debian Wheezy (stable), OpenSSL 1.0.1e-2+deb7u4
- Ubuntu 12.04.4 LTS, OpenSSL 1.0.1-4ubuntu5.11
- CentOS 6.5, OpenSSL 1.0.1e-15
- Fedora 18, OpenSSL 1.0.1e-4
- OpenBSD 5.3 (OpenSSL 1.0.1c 10 May 2012) and 5.4 (OpenSSL 1.0.1c 10 May 2012)
- FreeBSD 8.4 (OpenSSL 1.0.1e) and 9.1 (OpenSSL 1.0.1c)
- NetBSD 5.0.2 (OpenSSL 1.0.1e)
- OpenSUSE 12.2 (OpenSSL 1.0.1c)
阿維自己剛有幾台機器是使用CentOS 6.5架設的,這樣的資安問題當然要趕緊修復,以下就跟大家分享修復的方式
執行 yum update openssl
Installed Packages
Name : openssl
Arch : x86_64
Version : 1.0.1e
Release : 16.el6_5.4
Size : 4.0 M
Repo : installed
From repo : ami-updates
Summary : A general purpose cryptography library with TLS implementation
URL : http://www.openssl.org/
License : OpenSSL
Description : The OpenSSL toolkit provides support for secure communications
: between machines. OpenSSL includes a certificate management tool
: and shared libraries which provide various cryptographic
: algorithms and protocols.</code>
Available Packages
Name : openssl
Arch : i686
Version : 1.0.1e
Release : 16.el6_5.7
Size : 1.5 M
Repo : updates
Summary : A general purpose cryptography library with TLS implementation
URL : http://www.openssl.org/
License : OpenSSL
Description : The OpenSSL toolkit provides support for secure communications
: between machines. OpenSSL includes a certificate management tool
: and shared libraries which provide various cryptographic
: algorithms and protocols.
Name : openssl
Arch : x86_64
Version : 1.0.1e
Release : 16.el6_5.7
Size : 1.5 M
Repo : updates
Summary : A general purpose cryptography library with TLS implementation
URL : http://www.openssl.org/
License : OpenSSL
Description : The OpenSSL toolkit provides support for secure communications
: between machines. OpenSSL includes a certificate management tool
: and shared libraries which provide various cryptographic
: algorithms and protocols.
注意! 不是更新完就沒事了,記得要做下面的動作
lsof -n | grep ssl | grep DEL
執行這段指令之後,會列出需要重新啟動的服務,記得將列出的服務全部重新啟動一次。
重新啟動服務之後,再執行一次這段指令,確保所有需要重新啟動的服務都已經完成重新啟動。
最近把PHP升級到5.4之後,原本很習慣使用eAccelerator就沒有repo可以安裝使用。比較了一下之後,發現APC還蠻多人推薦的,因此就決定用它了。
1. 安裝remi repo
在安裝APC加速器之前,我們必須要先安裝remi 這個repo
如果你跟我一樣所使用的AMI是Amazon Linux AMI x64,請使用下面的指令安裝remi
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6.rpm
如果你所使用的是RHEL x64,請同時安裝EPEL這個repo
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
安裝完畢之後,我們必須要啟用remi這個repo
sudo vim /etc/yum.repos.d/remi.repo
把enabled改成1,我習慣也會把remi的權重調整一下,在enabled之前加上這一行
priority=1
2. 安裝APC加速器
2-1 連同APC管理介面一起安裝的指令
sudo yum install apc-panel
2-2 只單純安裝APC加速器
sudo yum install php-pear php-pecl-apc
這樣就完成安裝了
3. 設定APC加速器管理的存取權限
如果在第二步你選擇只安裝APC加速器,那麼可以跳過這個步驟,直接到步驟四
sudo vi /etc/httpd/conf.d/apc-panel.conf
加入我們允許存取的IP
# # APC Control Panel
Alias /apc-panel /usr/share/apc-panel
<Directory /usr/share/apc-panel>
<IfModule mod_authz_core.c>
# Apache 2.4
Require local
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
Allow from 加入你允許存取的IP
</IfModule>
</Directory>
4. 重新啟動Apache
sudo service httpd restart
這樣就完成了PHP-APC加速器的安裝,如果你有安裝APC管理介面,那麼可以在 http://你的ip或domain/apc-panel 看到APC相關的資訊
AWS一向都以安全性為最優先的目標等級,我們可以使用IAM開啟兩階段式驗證來加強AWS Management Console登入,但是對於EC2的部分就需要由我們自己來進行加強。我自己的公司主機已經使用這樣的方式一段時間了,今天分享如何安裝、設定google兩段式驗證在我們的EC2上面,當然只要是Linux主機都可以裝上這個套件,另外也會針對後續使用上做一些說明。
這裡我用 Amazon Linux AMI 2013.03.1 這個AMI來進行說明
1. 修改hostname
我們先修改一下hostname,如果已經修改過的就可以跳過,當然也可以不修改,修改的原因是為了讓我們比較好識別動態密碼
[[email protected] ~]# hostname hsdn_jp_g2a
看下面的這張截圖,大家就知道為什麼要改hostname,當我們有很多主機都啟用兩段式驗證的時候,我們自己定義名稱是不是比ip來的容易識別呢?

2. 這樣的修改當重開機之後,hostname就會被還原,所以建議繼續下面的步驟
[[email protected] ~]# vim /etc/sysconfig/network
修改這行 HOSTNAME=localhost.localdomain
把localhost.localdomain改成跟我們剛剛設定的hostname相同就可以
3. 接下來就要開始進行google兩段式驗證套件的安裝
之前阿維在公司的新主機上面安裝了Cent OS 6 x64之後,一直沒有辦法找到CentALT相對應的源,今天意外發現CentALT已經發布了Cent OS 6版本的源,立刻就把這個源建立起來,不然等官方發布更新真的會等到頭髮都白了。
1. 建立centalt.repo
指令: vi /etc/yum.repos.d/centalt.repo
2. 將下面的內容貼進去
[CentALT]
name=CentALT Packages for Enterprise Linux 6 – $basearch
baseurl=http://centos.alt.ru/repository/centos/6/$basearch/
enabled=1
gpgcheck=0
3. 存檔後離開
4. 執行以下指令,啟用EPEL這個源
32 位元
rpm -ihv http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm
64 位元
rpm -ihv http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
我的公司使用AD進行使用者驗證,因此在使用者操作的便利性考量前提下.如何讓使用者不需要重覆輸入帳號與密碼,而直接抓取使用者已經登入AD的帳號資訊,已經變成系統開發必須要考量的項目之一 (至少我自己是這樣認為啦 @@)
.NET整合AD的資訊已經有大大實做成功並且實際運用於目前的系統上.由於都是微軟家族的產品,因此整合上比較容易.
但是目前公司存在有Apache+PHP+MySQL on Windows的架構,因此如何讓這樣的架構也可以快速的抓取使用者AD資訊是我今天要介紹的項目.
[版本需求]
1. Apache 2.x 以上
2. PHP和MySQL都沒有特殊的版本要求,不過我還是建議安裝PHP 5.x和MySQL 4.1.x以上的版本
[安裝過程]
1. 將mod_auth_sspi.so (下載位址)放到path_to_apache/modules這個目錄下面
2. 在httpd.conf裡面加上下面兩段
(1) LoadModule sspi_auth_module modules/mod_auth_sspi.so
(2)在需要進行驗證的目錄設定加上下面的內容,並且將AllowOverride開啟
AuthName "A Protected Place"
AuthType SSPI
SSPIDomain tpe.compalcomm.com
SSPIAuth On
SSPIAuthoritative On
SSPIOfferBasic On
require valid-user
修改後應該會像這樣
<Directory "D:/Develop/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
AuthName "A Protected Place"
AuthType SSPI
SSPIDomain tpe.compalcomm.com
SSPIAuth On
SSPIAuthoritative On
SSPIOfferBasic On
require valid-user
</Directory>
3. 重新啟動Apache
[如何抓取使用者登入AD的帳號]
程式只有一行,真的只有一行.
$_SERVER["REMOTE_USER"] 就只需要這行就可以抓到使用者登入AD的帳號.
後面要怎麼達成one single signon,我相信各位程式高手都知道該怎麼做了,我就不獻醜了.
[如何抓取使用者在AD中的其他資訊]
我之前有找到一個adLDAP.php的class,只需要確定ldap_binding正常,
然後將剛剛抓到的使用者AD帳號傳進去,AD裡面所有的資訊全部都可以抓出來.
adLDAP http://adldap.sourceforge.net/