aliyun折腾记录
緣起
最早淘寶購買的一臺vps突然抽風,聯系運維也沒結果,一怒之下就斷續了,之后半年就處于空檔期。最近被推送了一個aliyun輕量化服務器的廣告,1G cpu+1G ram+40G disk+1T 流量只要24元/月,還算實惠,就買了一臺。總結如下,aliyun只適合玩玩,不適合做梯子。
?
第一部分
系統
aliyun原裝系統
個人比較喜歡debian,所以選擇的系統鏡像是debian8.9。目前debian已經發展到debian9,對于debian8的維護已經停止,所以使用apt update時只能用jessie,其他例如jessie-updates都會出錯。
deb https://xxx.xxx/debian/ jessie main contrib non-free 這行不會出錯
deb https://xxx.xxx/debian/ jessie-updates main contrib non-free 這行會出錯
出錯信息
W: Failed to fetch http://ftp.uk.debian.org/debian/dists/jessie-updates/InRelease Unable to find expected entry 'main/source/Sources' in Release file (Wrong sources.list entry or malformed file)?
?從Jessie升級到Stretch
所以安裝完aliyun提供的debian8.9后,第一件要做的事就是升級到debian9,步驟如下:
1. su - root2. apt update && apt upgrade && apt dist-upgrade
3. vim /etc/apt/sourecs.list,將jessie替換為stretch(s/jessie/stretch/g)。注:aliyun鏡像提供的apt源是寫在/etc/apt/sources.list.d/sources.aliyun-*.list中,可以刪除或修改
4. apt update && apt upgrade 這是最小化升級
5. apt dist-upgrade 這是完全升級
6. apt autoremove && apt clean 升級完成后卸載不需要的軟件包和清理升級緩存
7. reboot
8. lsb_release -a 查看debian版本
?
?Debian軟件源格式說明
字段1 字段2 字段3 字段4 deb http://mirrors.163.com/debian/ wheezy main non-free contrib?
字段1 --- 軟件包格式
deb --------------- 安裝二進制包deb-src ---------- 安裝源代碼包?
?
字段2 --- 源路徑,可以有以下類型
http://ftp://cdrom:/file:/https:// 注:使用https需要額外安裝apt-transport-https?
?
字段3 --- 版本號+附加限定
示例jessie-securityjessie-updatesjessie-proposedjessie-backports版本號oldstable --- 代表上一個穩定版本stable --- 代表當前穩定版本testing --- 正在測試的版本sid(unstable) --- 正在開發的版本,無穩定保證wheezy --- Debian7的版本代號jessie --- Debian8的版本代號stretch --- Debian9的版本代號附加限定Security - Important Security Updates. Updates - Recommended Updates. Proposed - Pre-released Updates. Backports - Unsupported Updates.?
字段4
main Debian里最基本及主要且符合自由軟件規范的軟件 ( packages )。 contrib 這里頭軟件雖然可以在 Debian 里頭運作,即使本身屬于自由軟件但多半卻是相依于非自由 ( non-free ) 軟件。 non-free 不屬于自由軟件范疇的軟件。 non-us 這個分類里頭的軟件都來自非美國地區,當中可能有牽扯到專利、加密..等等問題。 marillat 對應 Christian Marillat 的軟件倉庫,包括mplayer, transcode等。 rareware 對應 rarewares.org 的軟件倉庫, 包括很多音效程序,如lame, musepack, beep media player等。 ustc 對應 debian@ustc 維護的一些軟件包,如 mule-gbk, gaim-openq, scim, stardict dicts, patched xpdf, irssi, xmms。 java 對應 Blackdown java。包括 j2re, j2sdk ,mozilla java plugin。 firefly 對應打過firefly補丁的包,包括 fontconfig mozilla mozilla-firefox pango1.0 qt-x11-free xft misc 對應其它無分類的包,包括 nvidia-kernel, winex3, rox, chmsee等?
?
?
增加sudo權限
默認的普通用戶沒有sudo權限,按照如下步驟增加sudo權限。
1. 可以修改/etc/sudoers,添加如下語句,xxx代表需要加sudo的普通賬號。
# User privilege specification root ALL=(ALL:ALL) ALL xxx ALL=(ALL) ALL?
?2. 按照官方文檔建議,不要直接修改/etc/sudoers,官方文檔如下。
# As of Debian version 1.7.2p1-1, the default /etc/sudoers file created on # installation of the package now includes the directive: # # #includedir /etc/sudoers.d # # This will cause sudo to read and parse any files in the /etc/sudoers.d # directory that do not end in '~' or contain a '.' character. # # Note that there must be at least one file in the sudoers.d directory (this # one will do), and all files in this directory should be mode 0440. # # Note also, that because sudoers contents can vary widely, no attempt is # made to add this directive to existing sudoers files on upgrade. Feel free # to add the above directive to the end of your /etc/sudoers file to enable # this functionality for existing installations if you wish! # # Finally, please note that using the visudo command is the recommended way # to update sudoers content, since it protects against many failure modes. # See the man page for visudo for more information. #? 替代方案是在/etc/sudoers.d目錄下增加文件,文件名的要求是不能以~結尾和不能包含,文件的內容如下,xxx代表需要加sudo的普通賬號。
xxx ALL=(ALL) ALL?
配置SSH登陸
因為是自己玩的,所以想配置SSH只能自己登陸,方法如下。
1. 限制用戶
a. 白名單
在 /etc/ssh/sshd_config 配置文件中設置 AllowUsers 選項,(配置完成需要重啟 SSHD 服務)格式如下:AllowUsers aliyun test@192.168.1.1 # 允許 aliyun 和從 192.168.1.1 登錄的 test 帳戶通過 SSH 登錄系統。?
b. 黑名單
在/etc/ssh/sshd_config配置文件中設置DenyUsers選項,(配置完成需要重啟SSHD服務)格式如下: DenyUsers zhangsan aliyun #Linux系統賬戶 # 拒絕 zhangsan、aliyun 帳戶通過 SSH 登錄系統?
2. 限制IP
除了可以禁止某個用戶登錄,我們還可以針對固定的IP進行禁止登錄,linux 服務器通過設置 /etc/hosts.allow 和 /etc/hosts.deny 這個兩個文件,hosts.allow許可大于hosts.deny,可以允許或者限制某個或者某段IP地址遠程 SSH 登錄服務器。
1. vim /etc/hosts.allow, 添加sshd:192.168.0.1:allow #允許 192.168.0.1 這個 IP 地址 ssh 登錄 sshd:192.168.0.1/24:allow #允許 192.168.0.1/24 這段 IP 地址的用戶登錄?
?未完待續
轉載于:https://www.cnblogs.com/memphise/p/10905223.html
總結
以上是生活随笔為你收集整理的aliyun折腾记录的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: python的0基础入门语法_学习小结(
 - 下一篇: ULS 日志为空