Skip to content
WONGCW 網誌
  • 首頁
  • 論壇
  • 微博
  • 壁紙下載
  • 免費圖床
  • 視頻下載
  • 聊天室
  • SEO工具
  • 支援中心
  • 表格製作
  • More
    • 在線名片
    • 網頁搜索
    • 天氣預報
    • 二維碼生成器
    • WordPress 插件及主題下載
  • Search Icon

WONGCW 網誌

記錄生活經驗與點滴

Centos7 初始化配置

Centos7 初始化配置

2018-09-27 Comments 0 Comment

Centos7 初始化配置

[toc]

标签: Centos


安装EPEL源

yum install epel-release

修改epel源

[epel]
name=Extra Packages for Enterprise Linux 7 - basearch baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7  [epel-debuginfo] name=Extra Packages for Enterprise Linux 7 - basearch - Debug
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/basearch/debug #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 7 - basearch - Source baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/SRPMS #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

升级系统

yum update -y

update和upgrade的区别:
两者的作用都是将软件包升级到最新版。可是upgrade会考虑取代关系,如果有个包foo改名为foo2,那么upgrade会将foo升级为foo2并将foo删除!如果你的系统已经存在运行中的服务,且服务正常运行着,没重大的安全隐患不要使用upgrade升级系统。

升级系统而不升级内核

yum update --exclude=kernel* -y

安装常用包

Centos7 最小化安装很多命令都没有,比如ifconfig , netstat, 这时需要安装一些工具包,包括源码编译安装软件时的依赖

yum install -y pcre-devel openssl-devel libxslt* perl-ExtUtils-Embed at gcc-c++ python subversion gperf make rpm-build git curl bzip2-devel libcurl-devel gd gd-devel t1lib t1lib-devel libmcrypt libmcrypt-devel libtidy libtidy-devel GeoIP-devel libatomic_ops-devel zlib-devel unzip libstdc++* net-snmp net-snmp* gmp gmp-devel openldap openldap-devel libpcap-devel glib2-devel GeoIP-devel libxml2-devel libxml2-devel redis vim wget git htop iftop libtool make automake mlocate openssl-devel pam-devel unzip gcc screen openssl openssl-devel iptables-services bash-completion* pcre-devel openssl-devel libxslt* perl-ExtUtils-Embed at gcc-c++ python subversion gperf make rpm-build git curl bzip2-devel libcurl-devel gd gd-devel t1lib t1lib-devel libmcrypt libmcrypt-devel libtidy libtidy-devel GeoIP-devel libatomic_ops-devel zlib-devel unzip libstdc++* net-snmp net-snmp* gmp gmp-devel openldap openldap-devel net-tools

关闭一些程序

selinux

具体也不知道干嘛的,据说是美国的什么安全的什么鬼东西,具体去百度。启用了这个有些服务莫名其妙不能启动,索性关掉。

#打开selinux的配置文件
vim /etc/selinux/config

#将第7行的enforcing改为disabled
SELINUX=disabled

#保存退出
#这时需要重启才会生效,可以使用命令临时关闭
setenforce 0

firewalld

默认防火墙,CentOS7与CentOS6的区别之一使用firewalld替代了之前一直使用iptables,个人觉得iptables用起来更加顺手。

#禁止开机启动
systemctl disable firewalld

#立即停止服务
systemctl stop firewalld

使用 iptables

启用iptables

#设置iptables为开机启动
systemctl enable iptables

#立即启动iptables
systemctl start iptables

#禁止IPv6的ip6tables开机启动
systemctl disable ip6tables

#立即停止IPv6的ip6tables
systemctl stop ip6tables

设置iptables

  • 查看防火墙规则
#通过以下命令查看iptables现有的规则,包含INPUT,FORWARD,OUTPUT
iptables -L -vn --line-number

#通过以下命令查看iptables现有nat的规则,包含PREROUTING,INPUT,OUTPUT,POSTROUTING
iptables -L -vn -t nat --line-number
  • 修改iptables

iptables配置文件路径/etc/sysconfig/iptables

iptables 文件修改完成后需要重启服务器

配置SSH

无论你的服务器是用在外网还是内网,默认的SSH端口都必须更改。安全是最重要的。同时使用证书登陆,那就更好了。

#编辑sshd_config文件
vim /etc/ssh/sshd_config

#修改端口,在#Port 22这一行下添加,端口号请自行选择。
Port 9099

#修改PasswordAuthentication字段为no
PasswordAuthentication no

#保存退出

生成ssh key

#通过以下命令生成key(密钥对)
ssh-keygen -t rsa -b 4096

#这里回车即可
Enter file in which to save the key (/root/.ssh/id_rsa):

#这里请为你的key设置一个密码,用key登录的时候需要密码才能解锁key。这是保护key的一种有效的方法。
#密码留空并回车即为空密码,不安全!
Enter passphrase (empty for no passphrase):

#重命名密钥,有些主机以内置密钥,覆盖前请确认。
mv .ssh/id_rsa.pub .ssh/authorized_keys

#查看key并保存到本地,然后删除。
cat .ssh/id_rsa

#留密钥在服务器内就足够了,key删掉以保安全。前提是你已经保存到本地!要不然你将不能通过SSH登陆服务器!
rm -f .ssh/id_rsa

重启SSH服务

systemctl restart sshd

修改hostname

如果你有多台服务器,那hostname将是区分这些服务器最好的方法。你可以通过以下命令进行修改

hostnamectl set-hostname [your-hostname]

#例如
hostnamectl set-hostname test1

#重启生效

分享此文:

  • 分享到 Twitter(在新視窗中開啟)
  • 按一下以分享至 Facebook(在新視窗中開啟)
  • 分享到 WhatsApp(在新視窗中開啟)
  • 按一下以分享到 Telegram(在新視窗中開啟)
  • 分享到 Pinterest(在新視窗中開啟)
  • 分享到 Reddit(在新視窗中開啟)
  • 按一下即可分享至 Skype(在新視窗中開啟)
  • 按一下即可以電子郵件傳送連結給朋友(在新視窗中開啟)
  • 點這裡列印(在新視窗中開啟)

相關


Linux資訊

Post navigation

PREVIOUS
iOS 12.1 beta 1 已开启 eSIM 功能 但还需等运营商
NEXT
更新CentOS7上的内核版本 Update The Version Of Kernel On CentOS7

發表迴響 取消回覆

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料。

More results...

Generic filters
Exact matches only
Search in title
Search in content
Search in excerpt
Filter by 分類
網站公告
Featured
限時免費
ESET NOD32
WINDOWS 10 &11 INSIDER PREVIEW
Windows 軟件下載
系統軟件
辦公軟件
圖像處理
影音媒體
網絡軟件
應用軟件
Mac 軟件下載
安卓軟件下載
網絡資訊
Mac資訊
Linux資訊
VPS資訊
NASA資訊
金融資訊
WhatsApp Stickers教學
WordPress資訊
WeChat資訊
PHP資訊
Plesk資訊
TensorFlow
教學資源
開源程序
網頁工具
SEO工具
醫療健康
旅遊及消閒
其他資訊
Content from
Content to
2018 年 9 月
一 二 三 四 五 六 日
 12
3456789
10111213141516
17181920212223
24252627282930
« 8 月   10 月 »

分類

  • 網站公告
  • 限時免費
  • ESET NOD32
  • WINDOWS 10 &11 INSIDER PREVIEW
  • Windows 軟件下載
  • 系統軟件
  • 辦公軟件
  • 圖像處理
  • 影音媒體
  • 網絡軟件
  • 應用軟件
  • Mac 軟件下載
  • 安卓軟件下載
  • 網絡資訊
  • Mac資訊
  • Linux資訊
  • VPS資訊
  • NASA資訊
  • WhatsApp Stickers教學
  • WordPress資訊
  • WeChat資訊
  • PHP資訊
  • Plesk資訊
  • TensorFlow
  • 教學資源
  • 開源程序
  • 網頁工具
  • SEO工具
  • 醫療健康
  • 旅遊及消閒
  • 其他資訊

彙整

近期文章

  • A Guide to Overcoming Your Incontinence Problem as an Adult 2023-02-04
  • 美國聯邦貿易委員會不懼首戰失利準備對亞馬遜提起可能的反壟斷訴訟 2023-02-04
  • 科學家發現機械刺激可用於強化肌肉 2023-02-04
  • 報導稱巴基斯坦監管機構已經封鎖了維基百科的訪問 2023-02-04
  • 歐盟已經就動視暴雪的交易向微軟發出了正式警告 2023-02-04
  • SUCOM網絡使偏遠地區送貨的無人機有了更可靠的蜂窩通訊能力 2023-02-04
  • 馬斯克表示Twitter將在今天開始與創作者分享廣告收入 2023-02-04
  • 科學家垂直堆疊子像素帶來更清晰的microLED顯示器 2023-02-04
  • 2022年全球智能手機出貨量為2013年以來最低蘋果獨得85%營業利潤 2023-02-04
  • 哥倫比亞一位法官剛剛使用ChatGPT做出了一項法庭裁決 2023-02-04

熱門文章與頁面︰

  • DP vs HDMI 誰才是遊戲玩家最佳選擇?
  • ESET NOD32 LICENSE KEY (UPDATED 2023-01-17)
  • Explorer Patcher:讓Windows 11恢復Windows 10的行為特徵
  • 打車叫到特斯拉不會開門很尷尬?官方介紹開關門方法
  • ESET NOD32 LICENSE KEY (UPDATED 2022-01-01)
  • 盜版Windows 7還能免費升級Windows 10嗎?
  • Windows及OFFICE激活密鑰+電話激活教程–自用
  • z-sms – 在線免費云短信臨時手機號接碼平台網頁版
  • 百度雲盤、藍奏雲、微雲提取碼秘鑰查詢工具
  • 天翼網盤免登陸高速下載,直鏈解析不限速

投遞稿件

歡迎各界人士投遞稿件到admin@wongcw.com

請提供以下資料:

1.你的名字

2.你的電郵

3.分類目錄

4.文章標題

5.文章摘要

6.文章內容

7.文章來源

 

聯繫我們

查詢,投稿,商務合作:
​admin@wongcw.com
​技術支援:
​support@wongcw.com
​客户服務:
​cs@wongcw.com

QQ群:833641851

快帆

MALUS

極度掃描

DMCA.com Protection Status

WONGCW 網誌

  • 免責聲明
  • 捐助我們
  • ThemeNcode PDF Viewer
  • ThemeNcode PDF Viewer SC
  • Events

服務器提供

本站使用之服務器由ikoula提供。

聯繫我們

查詢,投稿,商務合作:
​admin@wongcw.com
​技術支援:
​support@wongcw.com
​客户服務:
​cs@wongcw.com

QQ群:833641851

© 2023   All Rights Reserved.
X