Blog

  • 使用openssl创建CSR文件

    在申请正规的ssl证书之前,需要先在本机生成CSR文件
    Login to your server via your terminal client (ssh). At the prompt, type:

    登陆ssh,在提示符下输入命令:

    openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr

    where server is the name of your server.
    这里是server.csr,自己根据自己情况命名。

    This will begin the process of generating two files: the Private-Key file for the decryption of your SSL Certificate, and a certificate signing request (CSR) file used to apply for your SSL Certificate. This command will prompt for the following X.509 attributes of the certificate:

    这将生成两个文件,一个是私钥文件用于解密你的SSL证书,还有就是用于申请SSL的证书签名请求CSR文件。

    在生成过程中有如下提示:
    Country Name (C): Use the two-letter code without punctuation for country, for example: US or CA.
    State or Province (S): Spell out the state completely; do not abbreviate the state or province name, for example: California.
    Locality or City (L): The Locality field is the city or town name, for example: Berkeley.
    Organization (O): If your company or department has an &, @, or any other symbol using the shift key in its name, you must spell out the symbol or omit it to enroll, for example: XY & Z Corporation would be XYZ Corportation or XY and Z Corportation.
    Organizational Unit (OU): This field is the name of the department or organization unit making the request.
    Common Name (CN): The Common Name is the Host + Domain Name. It looks like “www.company.com” or “company.com”.
    Please do not enter your email address, challenge password or an optional company name when generating the CSR.

    在生成CSR过程中,请不要填写email,强密码和备用公司名

    最后将生成server.csr

    如果要自认证证书 server.crt

    openssl x509 -req -in server.csr -signkey server.key -out server.crt

    计算 crt 的 finger print

    SHA-256
    openssl x509 -noout -fingerprint -sha256 -inform pem -in [certificate-file.crt] 
     
    SHA-1
    openssl x509 -noout -fingerprint -sha1 -inform pem -in [certificate-file.crt]
    
    MD5
    openssl x509 -noout -fingerprint -md5 -inform pem -in [certificate-file.crt] 
    
  • puppet master与agent认证

    首先要更改主机名和hosts
    时间要一致

    server端

    puppet master --verbose --no-daemon
    agent端
    puppet agent --server=master-test.hupu.com --no-daemonize --verbose --debug
    然后到master查看申请
    puppet cert --list
    通过申请
    puppet cert --sign agent-test.hupu.com
    清理不需要的申请
    puppet cert --clean agent-test.localdomain
    puppetca clean db2-1-220.jh.abc.com
    
    认证完成之后
    在agent上应用master上的配置
    puppet agent --server=master-test.hupu.com --no-daemonize --verbose --onetime
     master 端查看所有已经认证的机器
    puppetca list --all
    puppet cert list --all

  • iptables的表和链

    iptables包含 4 个表,5 个链

    其中表是按照对数据包的操作区分的,链是按照不同的Hook点来区分的,表和链实际上是netfilter的两个维度

    4个表:filter, nat, mangle, raw,默认表是filter(没有指定表的时候就是filter表)。表的处理优先级:raw>mangle>nat>filter

    filter:一般的过滤功能
    nat:用于nat功能(端口映射,地址映射等)
    mangle:用于对特定数据包的修改
    raw: 优先级最高,设置raw时一般是为了不再让 iptables 做数据包的链接跟踪处理,提高性能

    5个链:PREROUTING, INPUT, FORWARD, OUTPUT, POSTROUTING

    PREROUTING: 数据包进入路由表之前
    INPUT: 通过路由表后目的地为本机
    FORWARD: 通过路由表后,目的地不为本机
    OUTPUT: 由本机产生,向外转发
    POSTROUTIONG: 发送到网卡接口之前

  • 关闭烦人的IE安全风险提示

    IE提示“您的安全设置级别导致计算机存在安全风险”。有些网页做的很垃圾,必须降低安全风险,虽然微软初衷是好的,但是很烦人

    关闭方法如下:

    快捷键Win+R打开“运行”对话框,在对话框中输入gpedit.msc后回车打开组策略。

    依次展开“本地计算机策略 – 计算机配置 – 管理模块 – Windows 组件 – Internet Explorer”,在右边的窗口中找到“关闭安全设置检查功能”策略项。双击此项打开属性对话框,在“设置 ”选项中选择“已启用”项,确定生效后,以后就不会执行安全设置检查了,也不会再出现烦人的安全提示了。

  • 在xenserver中添加iso文件

    一般添加iso都是为了装系统

    首先,登录xenserver的命令行界面,执行以下命令:

    mkdir /boot-iso
    xe sr-create name-label=boot-iso type=iso device-config:location=/boot-iso device-config:legacy_mode=true content-type=iso

    这样就创建了iso的存储库(SR-Storage Repositories),在XenCenter中可以看到多了一个boot-iso

    接下来使用SFTP(如filezilla)上传iso文件至主机的/boot-iso即可。

    注:

    1.如果不小心创建错误,或重复新增,想删除存储库时,就使用 XenCenter,直接选择Detach即可。

    2.上传iso文件至主机后,如果XenCenter不能同步显示,在 console 执行xe-toolstack-restart,XenCenter就可以识别到。

  • 使用监控宝的snmp监控ubuntu

    snmp使用很方便,可以监控cpu, load average, memory, net, 磁盘I/O,监控宝(http://www.jiankongbao.com)提供了简单的snmp监控。

    在监控宝中找到添加snmp服务器,需要准备几样信息:

    *服务器的ip地址
    *snmp的用户名,密码

    这里使用snmp v3版本,同时使用md5加密

    安装snmpd

    apt-get install snmpd

    修改配置文件snmpd.conf,可以使用man snmpd.conf查看snmpd.conf具体段的设置

    vim /etc/snmp/snmpd.conf

    将监听本地ip改为监听所有

    即将agentAddress udp:127.0.0.1:161 改为 agentAddress udp:161

    接下来创建一个用户jpuyy,密码为jpuyy123,这里需要至少8位密码

    # net-snmp-config --create-snmpv3-user -ro -A jpuyy123 -a MD5 jpuyy
     adding the following line to /var/lib/snmp/snmpd.conf:
     createUser jpuyy MD5 "jpuyy123" DES
     adding the following line to /usr/share/snmp/snmpd.conf:
     rouser jpuyy

    可以发现自动将用户信息和权限记录到了不同的文件里。

    启动snmpd服务

    /etc/init.d/snmpd start

    最后检查一下防火墙是否打开了udp 161端口

    参考:

    http://wiki.jiankongbao.com/doku.php/%E6%96%87%E6%A1%A3:%E5%AE%89%E5%85%A8%E6%8C%87%E5%BC%95

    http://blog.jiankongbao.com/?p=160

    snmp小知识:简单网络管理协议(SNMP,Simple Network Management Protocol),snmp管理端叫做snmp manager;snmp代理端为snmp agent,存在于被管理的设备中。snmp是基于udp传输的。

    使用snmpwalk来取出snmp信息,不同版本使用的命令不一样。

    snmpwalk -v 2c -c public 192.168.1.8

    snmpwalk -v 1 -c public 192.168.1.8