久久午夜夜伦鲁鲁片免费无码影视,国产一区二区三区不卡av,无码人妻一区二区三区线,成人无码av片在线观看蜜桃

行業(yè)動(dòng)態(tài)

了解最新公司動(dòng)態(tài)及行業(yè)資訊

當(dāng)前位置:首頁(yè)>新聞中心>行業(yè)動(dòng)態(tài)
全部 4094 公司動(dòng)態(tài) 958 行業(yè)動(dòng)態(tài) 3136

有人會(huì)為新安裝的服務(wù)器立即設(shè)置保護(hù),確保只有你能夠進(jìn)入

時(shí)間:2022-04-28   訪問(wèn)量:2234

很少有人會(huì)立即為新安裝的服務(wù)器設(shè)置保護(hù),但我們生活的世界使它成為必需品。那么為什么這么多人要等到最后才設(shè)置保護(hù)呢?我也做過(guò)同樣的事情,通常歸結(jié)為想要直接去做有趣的事情。希望本文向您展示了保護(hù)服務(wù)器比您想象的要容易得多,并且當(dāng)攻擊開(kāi)始時(shí)從堡壘往下看會(huì)很有趣。

這篇文章是為 12.04.2 LTS 寫(xiě)的,但是你可以在其他 Linux 發(fā)行版上做類(lèi)似的事情。

我從哪里開(kāi)始?

如果服務(wù)器已經(jīng)有公共 IP,您將需要立即鎖定 root 訪問(wèn)權(quán)限。實(shí)際上,您需要完全鎖定 SSH 訪問(wèn)權(quán)限,以便只有您可以進(jìn)入。添加一個(gè)新用戶(hù)并將這個(gè)新用戶(hù)添加到一個(gè)管理組(在 /etc/ 中預(yù)先設(shè)置了 sudo 訪問(wèn)權(quán)限)。

## 添加用戶(hù)組 admin(譯者注)
$ sudo addgroup admin
Adding group 'admin' (GID 1001)
Done.
## 添加用戶(hù) spenserj(譯者注)
$ sudo adduser spenserj
Adding user `spenserj' ...
Adding new group `spenserj' (1002) ...
Adding new user `spenserj' (1001) with group `spenserj' ...
Creating home directory `/home/spenserj' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for spenserj
Enter the new value, or press ENTER for the default
    Full Name []: Spenser Jones
    Room Number []:
    Work Phone []:
    Home Phone []:
    Other []:
Is the information correct? [Y/n] y
## 追加用戶(hù) spenserj 到用戶(hù)組 admin 中(譯者注)
$ sudo usermod -a -G admin spenserj

您還需要在您的計(jì)算機(jī)上創(chuàng)建一個(gè)私鑰并在服務(wù)器上禁用密碼驗(yàn)證。

(公鑰也要加到服務(wù)器.sshd文件中,詳見(jiàn)文末參考鏈接第三步。譯者注)

## 本地主機(jī)用戶(hù)主目錄下新建 .ssh 文件,并將公鑰追加到 authorized_keys(譯者注)
$ mkdir ~/.ssh
$ echo "ssh-rsa [your public key]" > ~/.ssh/authorized_keys
PermitRootLogin no
PermitEmptyPasswords no
PasswordAuthentication no
AllowUsers spenserj

重新加載 SSH 以應(yīng)用更改,然后嘗試登錄新會(huì)話以確保一切正常。如果您無(wú)法登錄,您仍然可以使用原始會(huì)話來(lái)解決問(wèn)題。

## 重啟 ssh(譯者注)
$ sudo service ssh restart
ssh stop/waiting
ssh start/running, process 1599

更新服務(wù)器

現(xiàn)在只有你可以訪問(wèn)服務(wù)器服務(wù)器運(yùn)維,不用擔(dān)心黑客潛入,又可以正常呼吸了。您的服務(wù)器很可能有一些更新,所以現(xiàn)在開(kāi)始運(yùn)行它們。

## 服務(wù)器更新(譯者注)
$ sudo apt-get update
...
Hit http://ca.archive.ubuntu.com precise-updates/universe Translation-en_CA
Hit http://ca.archive.ubuntu.com precise-updates/universe Translation-en
Hit http://ca.archive.ubuntu.com precise-backports/main Translation-en
Hit http://ca.archive.ubuntu.com precise-backports/multiverse Translation-en
Hit http://ca.archive.ubuntu.com precise-backports/restricted Translation-en
Hit http://ca.archive.ubuntu.com precise-backports/universe Translation-en
Fetched 3,285 kB in 5s (573 kB/s)
Reading package lists... Done
## 服務(wù)器升級(jí)(譯者注)
$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
  linux-headers-generic-lts-quantal linux-image-generic-lts-quantal
The following packages will be upgraded:
  accountsservice apport apt apt-transport-https apt-utils aptitude bash ...
73 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Need to get 61.0 MB of archives.
After this operation, 151 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
...
Setting up libisc83 (1:9.8.1.dfsg.P1-4ubuntu0.6) ...
Setting up libdns81 (1:9.8.1.dfsg.P1-4ubuntu0.6) ...
Setting up libisccc80 (1:9.8.1.dfsg.P1-4ubuntu0.6) ...
Setting up libisccfg82 (1:9.8.1.dfsg.P1-4ubuntu0.6) ...
Setting up libbind9-80 (1:9.8.1.dfsg.P1-4ubuntu0.6) ...
Setting up liblwres80 (1:9.8.1.dfsg.P1-4ubuntu0.6) ...
Setting up bind9-host (1:9.8.1.dfsg.P1-4ubuntu0.6) ...
Setting up dnsutils (1:9.8.1.dfsg.P1-4ubuntu0.6) ...
Setting up iptables (1.4.12-1ubuntu5) ...
...

安裝防火墻

現(xiàn)在正在運(yùn)行最新的軟件?這很好。繼續(xù)構(gòu)建防火墻,只允許你現(xiàn)在需要的東西。您可以在之后添加一個(gè)例外,幾分鐘的額外工作不會(huì)讓您崩潰。它是預(yù)裝在的,所以先給它設(shè)置一些規(guī)則。

$ sudo mkdir /etc/iptables
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
# Accept any related or established connections
-I INPUT  1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-I OUTPUT 1 -m state --state RELATED,ESTABLISHED -j ACCEPT
# Allow all traffic on the loopback interface
-A INPUT  -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
# Allow outbound DHCP request - Some hosts (Linode) automatically assign the primary IP
#-A OUTPUT -p udp --dport 67:68 --sport 67:68 -j ACCEPT
# Outbound DNS lookups
-A OUTPUT -o eth0 -p udp -m udp --dport 53 -j ACCEPT
# Outbound PING requests
-A OUTPUT -p icmp -j ACCEPT
# Outbound Network Time Protocol (NTP) request
-A OUTPUT -p udp --dport 123 --sport 123 -j ACCEPT
# SSH
-A INPUT  -i eth0 -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
# Outbound HTTP
-A OUTPUT -o eth0 -p tcp -m tcp --dport 80 -m state --state NEW -j ACCEPT
-A OUTPUT -o eth0 -p tcp -m tcp --dport 443 -m state --state NEW -j ACCEPT
COMMIT

通過(guò) -apply 應(yīng)用超時(shí)規(guī)則集,如果連接丟失,請(qǐng)修復(fù)規(guī)則并在繼續(xù)之前重試。

$ sudo iptables-apply /etc/iptables/rules
Applying new ruleset... done.
Can you establish NEW connections to the machine? (y/N) y
... then my job is done. See you next time.

使用以下內(nèi)容創(chuàng)建文件 /etc//if-pre-up.d/。這將在啟動(dòng)服務(wù)器時(shí)自動(dòng)加載規(guī)則。

#!/bin/sh
iptables-restore < /etc/iptables/rules

現(xiàn)在給它執(zhí)行權(quán)限并執(zhí)行文件以確保它正確加載。

$ sudo chmod +x /etc/network/if-pre-up.d/iptables
$ sudo /etc/network/if-pre-up.d/iptables

想當(dāng)黑客的人

在安全性方面我最喜歡的工具之一,因?yàn)樗鼤?huì)監(jiān)控您的日志文件并暫時(shí)禁止濫用資源的用戶(hù),例如強(qiáng)制 SSH 連接或破壞您的網(wǎng)絡(luò)服務(wù)器。

## 安裝 fail2ban(譯者注)
$ sudo apt-get install fail2ban
[sudo] password for sjones:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  gamin libgamin0 python-central python-gamin python-support whois
Suggested packages:
  mailx
The following NEW packages will be installed:
  fail2ban gamin libgamin0 python-central python-gamin python-support whois
0 upgraded, 7 newly installed, 0 to remove and 2 not upgraded.
Need to get 254 kB of archives.
After this operation, 1,381 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
...

安裝了默認(rèn)配置(/etc//jail.conf),但我們想在 /etc//jail.local 中進(jìn)行更改,所以將其復(fù)制到那里。

## 拷貝配置(譯者注)
sudo cp /etc/fail2ban/jail.{conf,local}

配置

將線路更改為您的 IP 并決定阻止多長(zhǎng)時(shí)間(默認(rèn)為 10 分鐘)。您還需要設(shè)置一個(gè),我通常將其設(shè)置為我的電子郵件地址并輸入@.de。 .de 是一個(gè)跟蹤并自動(dòng)報(bào)告黑客試圖濫用其連接的 IP 的系統(tǒng)。

[DEFAULT]
# "ignoreip" can be an IP address, a CIDR mask or a DNS host
ignoreip = 127.0.0.1/8
bantime  = 600
maxretry = 3
# "backend" specifies the backend used to get files modification. Available
# options are "gamin", "polling" and "auto".
# yoh: For some reason Debian shipped python-gamin didn't work as expected
#      This issue left ToDo, so polling is default backend for now
backend = auto
#
# Destination email address used solely for the interpolations in
# jail.{conf,local} configuration files.
destemail = root@localhost,[email protected]

雖然默認(rèn)設(shè)置就足夠了,但還有一些其他設(shè)置需要檢查,因此請(qǐng)快速查看該部分的文件。

允許您對(duì)惡意活動(dòng)做出反應(yīng),但默認(rèn)為禁止,我們希望它禁止并發(fā)送電子郵件。幸運(yùn)的是服務(wù)器運(yùn)維,有一個(gè)預(yù)配置的可以完成這項(xiàng)工作。

# Choose default action.  To change, just override value of 'action' with the
# interpolation to the chosen action shortcut (e.g.  action_mw, action_mwl, etc) in jail.local
# globally (section [DEFAULT]) or per specific section
action = %(action_mwl)s

監(jiān)獄

為了讓它發(fā)揮作用,它需要知道該看什么。這是在配置的 Jails 部分中配置的,有許多實(shí)例被預(yù)加載和禁用。由于到目前為止您只啟用了 SSH 訪問(wèn),我們將只啟用 SSH 和 SSH-DDoS 監(jiān)獄,但您需要為安裝在該服務(wù)器上的每個(gè)可公開(kāi)訪問(wèn)的服務(wù)添加一個(gè)新的監(jiān)獄。

[ssh]
enabled  = true
port     = ssh
filter   = sshd
logpath  = /var/log/auth.log
maxretry = 6
[ssh-ddos]
enabled  = true
port     = ssh
filter   = sshd-ddos
logpath  = /var/log/auth.log
maxretry = 6

應(yīng)用更改

現(xiàn)在我們已經(jīng)配置好了,您將重新加載它并確保它向其中添加了適當(dāng)?shù)囊?guī)則。

$ sudo service fail2ban restart
 * Restarting authentication failure monitor fail2ban
   ...done.
$ sudo iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination
fail2ban-ssh-ddos  tcp  --  anywhere             anywhere             multiport dports ssh
fail2ban-ssh  tcp  --  anywhere             anywhere             multiport dports ssh
...
Chain fail2ban-ssh (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere
Chain fail2ban-ssh-ddos (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

您可以隨時(shí)使用 sudo -L 列出您的規(guī)則,然后是當(dāng)前禁止 IP 的列表。目前正在處理兩個(gè)惡意IP:

DROP       all  --  204.50.33.22         anywhere
DROP       all  --  195.128.126.114      anywhere

控制世界

現(xiàn)在您的服務(wù)器已鎖定并準(zhǔn)備就緒,這并不是您安全之旅的終點(diǎn)。密切關(guān)注更新(首先在非生產(chǎn)環(huán)境中進(jìn)行測(cè)試),始終關(guān)閉不需要的端口,定期檢查日志,并了解服務(wù)器內(nèi)外發(fā)生的情況。

跟蹤

有一些很好的評(píng)論,如果您對(duì)不同的視角和更高的安全性感興趣,我建議您閱讀它們。本文旨在作為初學(xué)者的安全指南,結(jié)束本文并不意味著您的服務(wù)器是無(wú)懈可擊的。使用本指南快速鎖定新服務(wù)器并根據(jù)您的獨(dú)特情況在其上進(jìn)行構(gòu)建。您可能想探索 IPV6 安全性、更改 SSH 端口(通過(guò)隱藏)、內(nèi)核安全性(和 )、跟蹤系統(tǒng)更改并進(jìn)行全面審核(如果您的服務(wù)器曾經(jīng)不安全,或者已經(jīng)在線很長(zhǎng)時(shí)間)。服務(wù)器有數(shù)百個(gè)入口點(diǎn),您安裝的每個(gè)應(yīng)用程序都可能引入另一個(gè)漏洞,但使用正確的工具,您可以放心上床。

參考鏈接:阮一峰Linux服務(wù)器的初步配置過(guò)程

上一篇:中國(guó)5大新型IT技術(shù)社區(qū),你都知道哪些?

下一篇:湖北IT公司客服外包智能客服招聘簡(jiǎn)章(10月21日)

發(fā)表評(píng)論:

評(píng)論記錄:

未查詢(xún)到任何數(shù)據(jù)!

在線咨詢(xún)

點(diǎn)擊這里給我發(fā)消息 售前咨詢(xún)專(zhuān)員

點(diǎn)擊這里給我發(fā)消息 售后服務(wù)專(zhuān)員

在線咨詢(xún)

免費(fèi)通話

24小時(shí)免費(fèi)咨詢(xún)

請(qǐng)輸入您的聯(lián)系電話,座機(jī)請(qǐng)加區(qū)號(hào)

免費(fèi)通話

微信掃一掃

微信聯(lián)系
返回頂部