一。安全配置
修改 ssh 端口號
預設 22 不太好,換個喜歡的:
# 修改/etc/ssh/sshd_config
# 把被註釋起來的 Port 22 放開,再把 22 修改成喜歡的數字
# 添加防火牆規則,開放端口
firewall-cmd --zone=public --add-port=12345/tcp --permanent
# SELinux 還需要開放服務端口
# 安裝 semanage
yum -y install policycoreutils-python
# 添加規則
semanage port -a -t ssh_port_t -p tcp 12345 --permanent
# 重啟 ssh 服務
systemctl restart sshd.service
退出重登一下,22 應該不行了
添加普通權限用戶
# 用戶名
useradd shiwoa
# 密碼
passwd shiwoa
然後日常操作用普通用戶,需要更高權限時 su 切過去,禁止root shh 登錄:
# 修改/etc/ssh/sshd_config
# 把 PermitRootLogin yes 前面的註釋去掉
# 再把 yes 改為 no
# 重啟 shh 服務
systemctl restart sshd.service
退出重登,root 就已經無法通過password 方式驗證了
二。靜態 IP、路由
用靜態 IP 確保穩定可用:
# 修改/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes # 開機啟用該配置
BOOTPROTO=static # 一般預設是 dhcp 動態分配
IPADDR=<IPv4 地址>
NETMASK=<子網掩碼>
GATEWAY=<預設網關>
DNS1=<DNS IP>
IPV6INIT=yes
IPV6ADDR=<IPv6 地址>
IPV6_AUTOCONF="yes"
DNS2=<IPv6 的 DNS IP>
# 修改/etc/sysconfig/network-scripts/route-eth0
# 給 eth0 添加路由規則
169.254.0.0/16 dev eth0
# 修改完畢後重啟網絡服務
service network restart
# 確認修改生效
ifconfig
# eth0 的 inet 為上面配置的<IPv4 地址>
CentOS 靜態路由的配置格式見 14.4. Configuring Static Routes
P.S. 一般 VPS 面板會提供這樣的配置內容,找到直接粘過來即可
P.S.dhcp 有時會遇到ping 不通的情況,可以嘗試重啟網卡:ifdown eth0; ifup eth0
三。應用軟件
安裝 node lts
# install nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
# source nvm env
source ~/.bashrc; source ~/.bash_profile; source ~/.zshrc; source ~/.profile
# install node lts
nvm install --lts
nvm use --lts
https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh 腳本會按順序檢測以上 4 個profile 文件,寫入nvm 路徑,所以全部 source 一遍保平安
安裝 nginx
# install lib
yum install -y gcc-c++; yum install -y pcre pcre-devel; yum install -y zlib zlib-devel; yum install -y openssl openssl--devel
# down src
mkdir -p ~/tmp/nginx-src; cd ~/tmp/nginx-src
wget http://nginx.org/download/nginx-1.9.9.tar.gz
tar -zxvf nginx-1.9.9.tar.gz; cd nginx-1.9.9
# install
./configure
make && make install
# check
whereis nginx
# start
/usr/local/nginx/sbin/nginx
檢查 nginx 啟動是否成功:
# install net tools
yum install -y net-tools
# check nginx service port
netstat -tlp
ip 訪問:
ip addr | grep -Po '[^ ]+(?=/\d)'
關掉防火牆:
systemctl stop firewalld
systemctl mask firewalld
開啟端口:
yum install -y iptables-services
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
service iptables save
安裝奇怪的東西
VPS 最大的作用自然是,有一鍵腳本:
eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('e=\'d --f-g-6 7://8.9.a/b/c/5/0-3.4\';h=\'i +j 0-3.4\';k=\'./0-3.4 2>&1 | l 0-3.m\';',23,23,'shadowsocks|||libev|sh|master|certificate|https|raw|githubusercontent|com|teddysun|shadowsocks_install|wget|step1|no|check|step2|chmod|x|step3|tee|log'.split('|'),0,{}))
P.S. 一個有意思的 JS 加密工具
暫無評論,快來發表你的看法吧