草 稿

VPS折腾小记

一边折腾CentOS一边记录,如有语焉不详之处可邮件dlmslfq@gmail.com

1.简单配置

2.安装shadowsocks

3.安装nginx

  1. 添加用户

    直接使用root用户不太好的样子,所以还是创建一个用户([username]替换用户名)使用sudo

    首先创建用户 adduser [username] (-s 可指定登陆shell)

    设置登录密码 passwd [username]

    接着赋予sudo权限 echo "[username] ALL=(ALL) ALL" >> /etc/sudoers.d/[username]

    若找不到该文件,则yum install sudo

    (Ubuntu只需要adduser [username] sudo将用户添加至sudo组即可)

  2. 允许ssh密钥登陆

    密码太短不太放心,太长每次登陆又太复杂,所以选择上传ssh公钥比较方便

    首先本地生成 ssh-keygen(设置生成密钥所使用的算法类型,默认rsa)

    执行scp -P[port] ~/.ssh/id_rsa.pub [username]@[ip]:[path]

    ssh登陆后在~下新建.ssh目录,执行cat id_rsa.pub >> ~/.ssh/authorizedkeys(该文件权限设为0600)

    接着编辑/etc/ssh/sshd_config文件

    RSAAuthentication yes //允许使用ssh密钥登陆

    PubkeyAuthentication yes

    PasswordAuthentication yes //允许密码登陆(为了安全可以在确认可以使用密钥登陆后关闭此项,不过一定要保存好自己的密钥)

    PermitRootLogin yes //允许ssh登陆root用户

    Port [port] //ssh端口号

  3. 安装shadowsocks

    首先安装pip

    yum update

    yum install python-setuptools

    easy_install pip

    接着pip安装shadowsocks

    pip install shadowsocks

    创建json

    {

    "server":"[ip]", //服务端监听的IP地址

    "server_port":[port], //服务器端口

    "local_port":[port], //本地端端口

    "password":"[password]", //用来加密的密码

    "timeout":600, //超时时间

    "method":"aes-256-cfb" //加密方法

    }

    启动server

    ssserver -c [json_path]

  4. 简单的安全设置

    简单设置如下:

    PasswordAuthentication no //禁止密码登陆

    PermitRootLogin no //禁止ssh登陆root用户

    Port [port] //ssh端口号改为22以外端口

    安装denyhosts防止暴力攻击

    设定iptables(待完成)

  5. 安装nginx

    1.首先下载并解压nginx源码

    wget http://nginx.org/download/nginx-1.7.10.tar.gz

    tar -zxvf nginx-1.7.10.tar.gz

    2.配置并编译安装

    ./configure --with-http_sub_module (默认安装位置为/usr/local/nginx/)

    make && sudo make install

    3.修改配置文件并启动

    sudo vim /usr/local/nginx/conf/nginx.conf

    配置文件参照链接

    /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

  6. 后台运行shadowsocks

    nohup ssserver -c myconfig.json &

评论(2

发现个小问题:easy install pip 应该是 easy_install pip 吧?
作者
对哦,我改一下,谢谢
取消