1.SSH优化

编辑/etc/ssh/sshd_config配置文件  //全部都应该设置为no
/etc/ssh/sshd_config //服务端配置文件
/etc/ssh/ssh_config //客户端配置文件
Port 52113 //修改端口52113
UseDNS no //修改为No会反向查询客户端主机名,进行验证,防止客户端欺骗
PermitRootlogin no //禁止root登录
PermitEmpasswords no //禁止使用空密码(默认为空)
ListenAddress 192.168.1.x //只运行服务器上的内网地址来进行远程连接,外网地址直接拒绝,可以用Vpn做跳,可以不做设置
GSSAPIAuthentication no //解决Linux之间使用ssh连接慢的问题
板进入局域网,通过这样来访问,更加的安全

 sed进行修改

[root@7mini ~]# sed -ir '12 iPort 52113\nUseDNS no\nPermitRootlogin no\nGSSAPIAuthentication no' /etc/ssh/sshd_config

[root@7mini ~]# /etc/init.d/sshd restart   //重启生效
Stopping sshd: [ OK ]
Starting sshd: [ OK ]

2.调整中文中文乱码

中文字符集调整,调整服务器端字符集, Xshell客户端连接工具也需要调整为UTF-8
[root@ student ~]# cat /etc/sysconfig/i18n //调整为zh注意大小写
LANG="zh_CN.UTF-8"
SYSFONT="latarcyrheb-sun16"
[root@oldboy ~]# source /etc/sysconfig/i18n //source配置文件生效
[root@oldboy ~]# echo $LANG
zh_CN.UTF-8 英文字符集调整
export LANG=en_US.UTF-8 //临时生效
sed或者 vim修改配置文件 “/etc/sysconfig/i18n” 更改 LANG="en_US.UTF-8"
> /etc/sysconfig/i18n && echo "LANG=en_US.UTF-8"> /etc/sysconfig/i18n && source /etc/sysconfig/i18n

3.时间同步

ntpdate ntp1.aliyun.com
cp /etc/chrony.conf{,.bak} vim /etc/chrony.conf
server ntp6.aliyun.com iburst systemctl start chronyd
systemctl enable chronyd #开机启动
systemctl restart chronyd
chronyc sources #查看同步源
[root@7mini-node2 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 203.107.6.88 2 6 17 31 +653us[+1965us] +/- 32ms<br><br>2)或者通过计划任务进行同步

 

[root@linux-node1 ~]# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab
[root@linux-node1 ~]# crontab -l
*/5 * * * * /usr/sbin/ntpdate time1.aliyun.com > /dev/null

4优化历史记录

history 查看历史记录 默认100条,防止黑客进入服务器,查看到机密信息
参数:
-c:清空历史记录
-d:指定删除一行
export HISTSIZE=5
[root@student ~]# export HISTSIZE=5 命令行只看见5条信息(控制终端)
[root@student ~]# history 查看是否只存留5条
730 history
731 ls
732 history
733 export HISTSIZE=5
734 history
[root@student ~]# echo 'export HISTSIZE=5' >>/etc/profile 写入全局配置文件,永久生效控制终端只有5条信息
[root@student ~]#source /etc/profile 立即生效 [root@student ~]# export HISTFILESIZE=5 ~/.bash_historty(控制用户家目录下的记录)
[root@student ~]# cat ~/.bash_history
Test
Welcome to xuliangwei Linux
EOF
Exit
[root@student ~]# echo 'export HISTFILESIZE=5' >>/etc/profile 写入全局配置文件,永久生效。当前用户家目录下~/.bash_history
[root@student ~]#source /etc/profile 立即生效 [root@student ~]# history -c 清空历史记录终端
[root@student ~]# history
734 history
export HISTTIMEFORMAT="%F %T `whoami`" 记录历史命令执行时间以及是谁执行(生产必加)

5  加大文件描述符

启动进程使用它来表示打开的文件。每个进程启动都会占用文件描述符,如果过文件描述符不够,会导致进程失败
ulinit -n 查看默认文件描述符
参数: -S:软 -H:硬
[root@student ~]# ulimit -SHn 65535 //临时生效调整文件描述符
[root@student ~]# echo "* - nofile 65535" >>/etc/security/limits.conf
//永久生效调整文件描述符(退出终端可生效)

6.调整yum源

[root@student ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup    //备份yum源
[root@student ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo //CentOS 6源

7. 下载必要的软件包

yum install -y vim wget openssl openssl-devel openssl pcre pcre-devel telnet setuptool ntsysv git python-urllib3 sqlite  sqlite-devel bzip2 bzip2-devel gcc gcc-c++ cmake lsof sysstat bind-utils ntp iftop iotop tree screen iftop ntpdate

  

8 关闭SElinux防火墙

修改/etc/selinux/config-->    SELINUX=enforcing修改为SELINUX=disabled
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 使用sed替换关闭selinux
getenforce 查看selinux当前环境
setenforce 临时关闭 1.开启 0.关闭 permissive
[root@localhost ~]# /etc/init.d/iptables stop
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:清除防火墙规则: [确定]
iptables:正在卸载模块: [确定]
[root@localhost ~]# chkconfig iptables off

9 修改系统的主机名称

vi /etc/sysconfig/network

HOSTNAME=localhost.localdomain  #修改localhost.localdomain为6mini
vi /etc/hosts 127.0.0.1 localhost.localdomain #修改localhost.localdomain为6mini

 9.内核优化参数

net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl =15
net.ipv4.tcp_retries2 = 5
net.ipv4.tcp_fin_timeout = 2
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_max_orphans = 32768
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_wmem = 8192 131072 16777216
net.ipv4.tcp_rmem = 32768 131072 16777216
net.ipv4.tcp_mem = 786432 1048576 1572864
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.ip_conntrack_max = 65536
net.ipv4.netfilter.ip_conntrack_max=65536
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=180
net.core.somaxconn = 16384
net.core.netdev_max_backlog = 16384
如下内容,如果不开启iptables防火墙,会报错
#net.bridge.bridge-nf-call-ip6tables = 0
#net.bridge.bridge-nf-call-iptables = 0
#net.bridge.bridge-nf-call-arptables = 0
#net.ipv4.ip_conntrack_max = 65536
#net.ipv4.netfilter.ip_conntrack_max=65536
#net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=180

10.锁定系统关键文件

[root@student ~]# chattr +i /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/inittab        锁定文件系统
[root@student ~]# lsattr /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/inittab 查看锁定文件
----i--------e- /etc/passwd
----i--------e- /etc/shadow
----i--------e- /etc/group
----i--------e- /etc/gshadow
----i--------e- /etc/inittab
[root@student ~]# chattr -i /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/inittab 解除锁定
[root@student ~]# lsattr /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/inittab 再次查看
-------------e- /etc/passwd
-------------e- /etc/shadow
-------------e- /etc/group
-------------e- /etc/gshadow
-------------e- /etc/inittab

11.隐藏版本号

[root@student ~]# >/etc/issue       清空版本信息
[root@student ~]# >/etc/issue = cat > /dev/null /etc/issue
[root@student ~]# cat >> /etc/motd << EOF 编辑/etc/motd (设置登录提示信息)
> Welcome to xuliangwei Linux
> EOF

  

 

  

 

  

  

CentOS6安装后的常见基础优化的更多相关文章

  1. 生产服务器环境最小化安装后 Centos 6.5优化配置备忘

    生产服务器环境最小化安装后 Centos 6.5优化配置备忘 作者:Memory 发布于:2014-8-13 15:00 Wednesday 服务器 本文 centos 6.5 优化 的项有18处: ...

  2. 生产服务器环境最小化安装后Centos 6.5优化配置备忘

    生产服务器环境最小化安装后 Centos 6.5优化配置备忘 本文 centos 6.5 优化 的项有18处,列表如下: 1.centos6.5最小化安装后启动网卡 2.ifconfig查询IP进行S ...

  3. Win10安装后必做的优化,解决磁盘100%占用

    Win10安装后必做的优化,解决磁盘100%占用 01关闭家庭组 控制面板–管理工具–服务– HomeGroup Listener和HomeGroup Provider禁用. 02关闭磁盘碎片整理.自 ...

  4. 生产服务器环境最小化安装后 Centos 6.5优化配置[转]

    内容目录 centos6.5最小化安装后配置网络: IP地址, 网关, 主机名, DNS 更新系统源并且升级系统 系统时间更新和设定定时任 创建普通用户并进行sudo授权管理 修改SSH端口号和屏蔽r ...

  5. Win 8.1 安装后要做的优化

    ①无光驱恢复电脑或重置系统(无需插入介质,本来老提示插入介质) 1.准备工作:win8iso,解压到任意非系统盘,解压后的路径假如是:H:\OS\win8   2.接着以管理员身份启动命令提示符,输入 ...

  6. Xshell安装后,使用的优化

    常见的远程连接软件 windows Xshell.secureCRT.Putty mac ssh命令.iterm2 手机 IOS-termius Android-JuiceSSH Xshell的优化 ...

  7. centos7刚安装需要的一些基础优化

    基本操作一:更改主机名 centos7有一个新的修改主机名的命令hostnamectl # hostnamectl set-hostname --static benjamin # vim /etc/ ...

  8. mysql编译安装后各种常见错误集锦

    1.ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', sys ...

  9. centos7安装后,一些小优化

    1.设置静态ip vim /etc/sysconfig/network-scripts/ifcfg-ens33 将BOOTPROTO=dhcp修改为BOOTPROTO=static ONBOOT=no ...

随机推荐

  1. Desert King 最小比率生成树 (好题)

    Description David the Great has just become the king of a desert country. To win the respect of his ...

  2. css常见水平居中

    行内元素居中 常见行内元素如文本,图片等居中时,通常是给父元素设置text-align:center 来实现.例如 HTML: <body> <div>我是文字,我要居中显示& ...

  3. mysql的数据库 索引

    1.两种主要的引擎:MyISAM和InnoDB 2.如何查看自己的表是什么类型:http://www.cnblogs.com/luosongchao/archive/2013/05/23/309592 ...

  4. Codeforces Round #380 (Div. 2)/729D Sea Battle 思维题

    Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the ...

  5. PHP系统编程--02.PHP守护进程化

    什么是守护进程? 一个守护进程通常补认为是一个不对终端进行控制的后台任务.它有三个很显著的特征:在后台运行,与启动他的进程脱离,无须控制终端.常用的实现方式是fork() -> setsid() ...

  6. hdu5828 Rikka with Sequence

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5828 [题解] 考虑bzoj3211 花神游历各国,只是多了区间加操作. 考虑上题写法,区间全为1打标记 ...

  7. HTML语意化

    1.什么是HTML语义化? 根据内容的结构化(内容语义化),选择合适的标签(代码语义化)便于开发者阅读.写出更优雅的代码的同时让浏览器的爬虫和机器很好地解析.  2.为什么要语义化? 为了在没有CSS ...

  8. perl中的lock

    #!/usr/bin/env perl -w use strict; use threads; use threads::shared; ; print "count的起始值为:$count ...

  9. linux安装lamp

    github https://github.com/zblogcn/zblogphp Installation If your server system: CentOS yum -y install ...

  10. 基于Django Form源码开发自定义Form组件

    import copy import re class ValidateError(Exception): def __init__(self, detail): self.detail = deta ...