姚宁的博客

CentOS配置备忘录

添加用户并配置ssh登录

# 添加用户
useradd yaoning
# 设置密码
passwd yaoning
# 将用户加入wheel组
gpasswd -a yaoning wheel
# 显示wheel组中的用户
lid -g wheel

# 编辑ssh配置
vim /etc/ssh/sshd_config
# 增加如下配置
AllowUsers yaoning
# 保存退出 重启ssh服务
/etc/init.d/sshd restart

# ssh 登陆新用户
ssh yaoning@xx.xx.xx.xx -p port
# 注意端口号 默认是20 具体参考 /etc/ssh/sshd_config中的Port配置

安装配置mysql

# 更新yum
sudo yum update
# 查找mysql 一般找不到
yum repolist all | grep mysql
# 手动添加mysql的rpm
wget http://repo.mysql.com/mysql80-community-release-el7-2.noarch.rpm
sudo rpm -ivh mysql80-community-release-el7-2.noarch.rpm
yum update
# 删除rpm
yum remove mysql-community-release-el7-5
# 查看最新的rpm 
# https://dev.mysql.com/downloads/repo/yum/

# 没有wget的需要安装wget
yum install wget
# 再查找就能找到了
yum repolist all | grep mysql
< mysql-connectors-community        MySQL Connectors Community      enabled:    56
< ...

# 安装mysql
sudo yum install mysql-server
# mysql 管理
sudo systemctl start mysqld
# 没有systemctl的可以使用 
/etc/init.d/mysqld start | stop | restart
# 查看mysql默认生成的密码
grep "password" /var/log/mysqld.log

# -----------------------------
# 配置安全向导
mysql_secure_installation
# 默认密码要求长度超过8 包含大小写字母及特殊符号 一路yes

# 修改密码强度为弱
SHOW VARIABLES LIKE 'validate_password%';
SET GLOBAL validate_password_policy=0;

# 新建数据库及用户 并给权限
CREATE DATABASE work;
CREATE USER work@localhost IDENTIFIED BY '-----';
GRANT ALL ON work.* TO work@localhost;

# 删除用户
SELECT User FROM mysql.user;
DELETE FROM mysql.user WHERE user='---';
GRANT ALL PRIVILEGES ON *.* TO *@* WITH GRANT OPTION;

# 添加IP权限
UPDATE USER SET host='125.227.77.194' WHERE user='work'; 
FLUSH PRIVILEGES;

安装shadowsocks

搬瓦工的shadowsocks的安装脚本目前只支持centos6
centos7就只能自行安装了

# 安装
wget --no-check-certificate -O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh
chmod +x shadowsocks-all.sh
./shadowsocks-all.sh 2>&1 | tee shadowsocks-all.log
# 卸载
./shadowsocks-all.sh uninstall
# 状态管理
/etc/init.d/shadowsocks-python start | stop | restart | status

其他

# 查看端口占用情况
netstat -tunlp

相关链接

useradd
passwd
wheel组
install mysql use yum
shadowsocks一键安装