该种方式是推荐的进行Automation认证的方式,好处在于安全性高,过时时间由本身控制,很差的地方在于你们在Windows上要生成证书比较麻烦,并且必须上传到Azure management和Automation,shell
Automation须要两个文件:.pfx证书用于用户自动化端链接Azure,.cer文件,Azure管理端证书文件,这两个文件必须互相匹配。windows
对于建立证书,我的比较推荐的办法,或者我喜欢用的方法,就是利用开源的openssl工具,几个命令快速搞定,我在个人本机安装的是Ubuntu on windows,很是方便,你们感兴趣能够参考:安全
http://cloudapps.blog.51cto.com/3136598/1761954服务器
通常的Linux上都自带了OpenSSL,若是没有须要安装一下,固然你用Windows的也能够,首先第一步,生成服务器端的X509文件和key,记住在此处生成的密码:app
$ openssl req -x509 -days 365 -newkey rsa:1024 -keyout server-key.pem -out server-cert.pemide
而后经过pem文件,key,利用openssl生成Azure automation须要的pfx文件:工具
$ openssl pkcs12 -export -in server-cert.pem -inkey server-key.pem -out mycert.pfxspa
最后,经过pem文件生成Azure服务器管理端须要的x.509的cer文件:命令行
$ openssl x509 -inform pem -in server-cert.pem -outform der -out mycert.cerorm
你也可使用Windows的makecert工具生成Azure须要的cer和pfx文件。
首先下载Windows SDK for Windows 10或者windows 8:
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
https://developer.microsoft.com/en-us/windows/downloads/windows-8-sdk
安装完成后在program Files下的Windows kits下能够看到makecert命令行,使用makecert生成cer文件:
makecert.exe -sky exchange -r -n "CN=AzureAutomation" -pe -a sha1 -len 2048 -ss My "AzureAutomation.cer"
生成cer文件之后,咱们可使用Powershell生成pfx文件,请用管理员权限打开Powershell:
#myautomation是pfx的密码,在导入到Azure Automation时须要使用
$MyPwd = ConvertTo-SecureString -String "myautomation" -Force –AsPlainText
# "AzureAutomation"是certificate的名字,在第一步生成的
$AzureCert = Get-ChildItem -Path Cert:\CurrentUser\My | where {$_.Subject -match "AzureAutomation"}
#导出生成pfx文件
Export-PfxCertificate -FilePath C:\AzureAutomation.pfx -Password $MyPwd -Cert $AzureCert
不管你是使用Linux仍是Windows生成证书,必须确保你有一个X509的cer证书和一个带密码的pfx证书,前者用于上传到management证书,pfx上传给runbook的资产做为受权凭证。
上传cer文件到Azure的管理证书,登录Azure的portal,选择设置,管理证书,而后再下方选择"上载",选择你在上述步骤中生成的.cer并选择肯定:
打开自动化管理帐号,选择资产,并在下方菜单中选择添加设置:
在添加类型中选择添加凭据,在凭据类型中选择证书,
选择在上述步骤中生成的pfx文件,输入密码,而后肯定,完成上传:
在后续章节中介绍如何使用凭证进行验证使用。