加密的一个简单但又实用的任务就是发送加密电子邮件。多年来,为电子邮件进行加密的标准一直是PGP(Pretty Good Privacy)。程序员Phil Zimmermann特别为电子邮件的保密编写的PGP。这个软件非常好用,迅速流传开来,成了许多程序员的必备工具。但是,它是商业软件,不能自由使用。作为PGP的替代,如今已经有一个开放源代码的类似产品可供使用。GPG(Gnu Privacy Guard),它不包含专利算法,能够无限制的用于商业应用。
环境
RHEL7.2 默认以安装GPG
GPG 2.0.22 libgcrypt 1.5.3
使用方法
生成密钥
使用--gen-key生成一副新的密钥对
1 2 3 4 5 6 7 8 9 10 11
$ gpg --gen-key gpg (GnuPG) 2.0.22; Copyright (C) 2013 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
请选择您要使用的密钥种类: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (仅用于签名) (4) RSA (仅用于签名) 您的选择?
第一段是版权声明,然后让用户自己选择加密算法。默认选择第一个选项,表示加密和签名都使用RSA算法。
1 2
RSA 密钥长度应在 1024 位与 4096 位之间。 您想要用多大的密钥尺寸?(2048)
这一步要让我们输入密钥长度,长度越长越安全,默认为2048。
1 2 3 4 5 6 7 8
您所要求的密钥尺寸是 2048 位 请设定这把密钥的有效期限。 0 = 密钥永不过期 <n> = 密钥在 n 天后过期 <n>w = 密钥在 n 周后过期 <n>m = 密钥在 n 月后过期 <n>y = 密钥在 n 年后过期 密钥的有效期限是?(0)
You need a user ID to identify your key; the software constructs the user ID from the Real Name, Comment and Email Address in this form: "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
gpg --verify test.txt.sig test.txt gpg: Signature made Wed 17 May 2017 04:12:50 PM CST using RSA key ID 74A64469 gpg: Good signature from "Zhang San <zhangsan@163.com>" gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 0B77 E327 B365 316D F112 4521 ABC0 9164 6058 BC49
$ sudo brctl addif xennet0 enp0s6 $ brctl show bridge name bridge id STP enabled interfaces docker0 8000.0242df249633 no xennet0 8000.0242688f16c2 no enp0s6
创建固定IP容器 创建容器需要分配固定IP,该IP需要业务层分配,并与bridge同网段。 eg:
1 2 3 4 5 6 7 8
$ docker run -d --name c1 --network xennet --ip 10.37.129.100 centos:7.3.1611 /usr/sbin/init $ docker run -d --name c2 --network xennet --ip 10.37.129.200 centos:7.3.1611 /usr/sbin/init $ brctl show bridge name bridge id STP enabled interfaces docker0 8000.0242df249633 no xennet0 8000.0242688f16c2 no enp0s6 veth990ee82 vethf1f6fcb
$ sudo ip link add vp16 type veth peer name vp19 $ sudo ip link add vp26 type veth peer name vp29 $ sudo ip link show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp0s5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 00:1c:42:c6:de:63 brd ff:ff:ff:ff:ff:ff 3: vp19@vp16: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether b6:62:99:1e:0c:2a brd ff:ff:ff:ff:ff:ff 4: vp16@vp19: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 1e:ea:cf:86:51:ab brd ff:ff:ff:ff:ff:ff 5: vp29@vp26: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 4e:16:07:e6:77:2c brd ff:ff:ff:ff:ff:ff 6: vp26@vp29: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether be:98:08:90:da:7a brd ff:ff:ff:ff:ff:ff
创建namespace ns19和ns29,并设置vp19和vp29的netns
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
$ sudo ip netns add ns19 $ sudo ip netns add ns29 $ sudo ip netns list ns19 ns29 $ sudo ip linkset netns ns19 vp19 $ sudo ip linkset netns ns29 vp29 $ sudo ip link show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp0s5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 00:1c:42:c6:de:63 brd ff:ff:ff:ff:ff:ff 4: vp16@if3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 1e:ea:cf:86:51:ab brd ff:ff:ff:ff:ff:ff link-netnsid 0 6: vp26@if5: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether be:98:08:90:da:7a brd ff:ff:ff:ff:ff:ff link-netnsid 1
$ sudo ip netns exec ns19 ip link show 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 3: vp19@if4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether b6:62:99:1e:0c:2a brd ff:ff:ff:ff:ff:ff link-netnsid 0 $ sudo ip netns exec ns29 ip link show 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 5: vp29@if6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 4e:16:07:e6:77:2c brd ff:ff:ff:ff:ff:ff link-netnsid 0
$ sudo ip linkset dev vp16 up $ sudo ip linkset dev vp26 up $ sudo ip netns exec ns19 ip linkset dev vp19 up $ sudo ip netns exec ns29 ip linkset dev vp29 up $ sudo ip addr add 192.168.200.16/24 dev vp16 $ sudo ip addr add 192.168.200.26/24 dev vp26 $ sudo ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:1c:42:c6:de:63 brd ff:ff:ff:ff:ff:ff inet 192.168.3.5/24 brd 192.168.3.255 scope global enp0s5 valid_lft forever preferred_lft forever inet6 fe80::21c:42ff:fec6:de63/64 scope link valid_lft forever preferred_lft forever 4: vp16@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 1e:ea:cf:86:51:ab brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 192.168.200.16/24 scope global vp16 valid_lft forever preferred_lft forever inet6 fe80::1cea:cfff:fe86:51ab/64 scope link valid_lft forever preferred_lft forever 6: vp26@if5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether be:98:08:90:da:7a brd ff:ff:ff:ff:ff:ff link-netnsid 1 inet 192.168.200.26/24 scope global vp26 valid_lft forever preferred_lft forever inet6 fe80::bc98:8ff:fe90:da7a/64 scope link valid_lft forever preferred_lft forever $ sudo ip netns exec ns19 ip addr add 192.168.200.19/24 dev vp19 $ sudo ip netns exec ns19 ip addr show 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 3: vp19@if4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether b6:62:99:1e:0c:2a brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 192.168.200.19/24 scope global vp19 valid_lft forever preferred_lft forever inet6 fe80::b462:99ff:fe1e:c2a/64 scope link valid_lft forever preferred_lft forever $ sudo ip netns exec ns29 ip addr add 192.168.200.29/24 dev vp29 $ sudo ip netns exec ns29 ip addr show 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 5: vp29@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 4e:16:07:e6:77:2c brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 192.168.200.29/24 scope global vp29 valid_lft forever preferred_lft forever inet6 fe80::4c16:7ff:fee6:772c/64 scope link valid_lft forever preferred_lft forever
mac上有很多流氓软件,尤其是你通过非app store安装的时候。今天我遇到了这样一个问题,mac的通知中心通知我Get it NOW!,这是SQLite Editor的一个广告推送。频率为每天一次,记住当它提示你get的时候,千万别点,点了便每天会自动打开App Store + Web来提示你购买。我操,真是烦死了。