账号A =》 应用1 迁移到 账号B =》 应用2
账号A =》 应用1 , 应用3
账号B =》 应用2, 应用4 (这些的应用2 实际是等待迁移过来后才有)
由于应用迁移后,应用1的client_secret会立即失效,这里建议使用测试的应用3生成client_secret,需要准备的参数
可以使用以下ruby脚本client-secret.rb命令生成client_secret
require 'jwt'
# Save your private key from Apple in a file called `key.txt`
key_file = 'key.txt'
# Your 10-character Team ID
team_id = 'your team_id'
# Your Services ID, e.g. com.aaronparecki.services
client_id = 'your app bundle_id'
# Find the 10-char Key ID value from the portal
key_id = 'key_id'
ecdsa_key = OpenSSL::PKey::EC.new IO.read key_file
headers = {
'kid' => key_id
}
claims = {
'iss' => team_id,
'iat' => Time.now.to_i,
'exp' => Time.now.to_i + 86400*180, # This will be valid for 180 days
'aud' => 'https://appleid.apple.com',
'sub' => client_id,
}
token = JWT.encode claims, ecdsa_key, 'ES256', headers
puts token
参考1.1
func getToken(cid string, csecret string) (access_token string){
url := "https://appleid.apple.com/auth/token"
body := fmt.Sprintf("grant_type=client_credentials&scope=user.migration&client_id=%s&client_secret=%s",cid, csecret)
headers := map[string]string{}
headers["Content-Type"] = "application/x-www-form-urlencoded"
res,_ := http.Post(url, body, headers)
fmt.Println(res)
access_token = jsoniter.Get([]byte(res), "access_token").ToString()
return
}
func getTransferSub(token string, uid string) string{
url := "https://appleid.apple.com/auth/usermigrationinfo"
body := fmt.Sprintf("sub=%s&target=%s&client_id=%s&client_secret=%s", uid, recipient_team_id, client_id, client_secret)
headers := map[string]string{}
headers["Content-Type"] = "application/x-www-form-urlencoded"
headers["Authorization"] = "Bearer " + token
res,_ := http.Post(url, body, headers)
fmt.Println(uid + ":" + res)
return jsoniter.Get([]byte(res), "transfer_sub").ToString()
}
参考 步骤2
func exchange(token string, transfer_sub string) (sub string, email string){
url := "https://appleid.apple.com/auth/usermigrationinfo"
body := fmt.Sprintf("transfer_sub=%s&client_id=%s&client_secret=%s", transfer_sub, rec_client_id, rec_client_secret)
headers := map[string]string{}
headers["Content-Type"] = "application/x-www-form-urlencoded"
headers["Authorization"] = "Bearer " + token
res,_ := http.Post(url, body, headers)
fmt.Println(transfer_sub + ":" + res)
sub = jsoniter.Get([]byte(res), "sub").ToString()
email = jsoniter.Get([]byte(res), "email").ToString()
return
}
apt-get install make gcc
vmware-config-tools (除了hgfs选择yes,其他默认即可)
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
cd /mnt/cdrom
tar xzvf VMwareTools-8.8.3-682996.tar.gz -C /tmp
cd /tmp/VMwareTools-8.8.3-682996
./vmware-install.pl
reboot
ls /mnt/hgfs
ctrl + command mac和虚拟机之间切换
alt + 方向键 多个命令行界面切换
sudo passwd root #初次设置root密码
apt-get install openssh-server #默认安装了openssh-client
ps aux | grep ssh #查看sshd进程
vim /etc/ssh/sshd_config #ssh server 配置
service ssh restart #重启ssh服务
PermitRootLogin yes #开启root登录
AuthorizedKeysFile #取消注释 开启ssh key文件登录
apt-get -d openjdk-7-jre-lib #下载不安装 下载目录 /var/cache/apt/archives
vim /etc/hostname #修改主机名
#shadowsocks
Github主页:
https://github.com/shadowsocks/shadowsocks
##Debian / Ubuntu apt-get install -y python-pip && pip install shadowsocks
##Centos: yum install python-setuptools && easy_install pip pip install shadowsocks
启动服务:
ssserver -p 8000 -k password -m rc4-md5 -d start
关闭服务:
ssserver -p 8000 -k password -m rc4-md5 -d stop
启动完成后,使用shadowsocks客户端连接即可,很方便,搭建起来也很快捷,对应的客户端在shadowsocks的github主页上面可以找到。
#pptp
安装步骤参考:
http://www.zhihu.com/question/20113381
1) 安装pptpd(VPN服务器)和ufw(防火墙)
sudo apt-get install pptpd ufw
2)修改ufw规则
sudo ufw allow 22
sudo ufw allow 1723
sudo ufw enable
3)编辑pptpd选项
sudo vim /etc/ppp/pptpd-options
打开文件后,找到以下三行注释掉
refuse-pap
refuse-chap
refuse-mschap
之后在最后的地方添加如下信息
ms-dns 8.8.8.8
ms-dns 8.8.4.4
4) 编辑IP信息以及客户端IP地址范围
sudo vim /etc/pptpd.conf
会打开一个文件,然后在最后添加:
localip 178.62.122.180 (这里改为你自己的VPS的ip地址)
remoteip 10.99.99.100-199 (这里不需要改动)
5)添加VPN用户登录信息,就是你登陆VPN的时候使用的用户名密码
sudo vim /etc/ppp/chap-secrets
按照以下模式添加一个用户账号
[Username] [Service] [Password] [Allowed IP Address]
例如,添加一个 用户名为pptpvpn,密码为fBRucTiXQtkr的vpn账号,可以创建多个,一行一个用户。
pptpvpn pptpd fBRucTiXQtkr *
6)重启pptpd
sudo /etc/init.d/pptpd restart
7)编辑系统设置
sudo vim /etc/sysctl.conf
去掉下面一行的注释,改完后为:
net.ipv4.ip_forward=1
重新加载系统设置
sudo sysctl -p
8)修改ufw防火墙设置
sudo vim /etc/default/ufw
DEFAULT_FORWARD_POLICY = "DROP"
改为:
DEFAULT_FORWARD_POLICY = "ACCEPT"
9)继续修改ufw防火墙设置
sudo vim /etc/ufw/before.rules
在文本最开始处复制添加如下内容:
# NAT table rules
*nat
:POSTROUTING ACCEPT [0:0]
# Allow forward traffic to eth0
-A POSTROUTING -s 10.99.99.0/24 -o eth0 -j MASQUERADE
# Process the NAT table rules
COMMIT
10)重启防火墙
sudo ufw disable && sudo ufw enable
更新:这里可能会看到一条Error信息: ERROR: problem running ufw-init
如果出现这个情况,在你确保没输入错误的命令时,请输入一下命令:
ufw --force enable
比如下载:
https://github.com/belm/belm.github.io/blob/master/_posts/2015-01-04-dns.markdown
这个md文件,在命令行执行
wget https://github.com/belm/belm.github.io/raw/master/_posts/2015-01-04-dns.markdown
只需要把blob替换成raw即可。
]]>