MSDeploy.exe可以作为管理员连接,但不能以任何其他Windows帐户连接

Mik*_*sen 15 asp.net iis windows-server-2008 iis-7.5 webdeploy

我正在将MSDeploy集成到我的构建过程中,并且在验证时遇到问题.以下命令工作正常:

msdeploy -verb:sync -source:appHostConfig="KitchenPC",computerName=192.168.0.3,userName=Administrator,password=secret -dest:package=c:\DeployTest\KPC.zip
Run Code Online (Sandbox Code Playgroud)

但是,这不起作用:

msdeploy -verb:sync -source:appHostConfig="KitchenPC",computerName=192.168.0.3,userName=kpcpublish,password=secret -dest:package=c:\DeployTest\KPC.zip
Run Code Online (Sandbox Code Playgroud)

并产生错误:

Error Code: ERROR_USER_NOT_ADMIN
More Information: Connected to '192.168.0.11' using the Web Deployment Agent Service, but could not authorize. Make sure you are an administ
rator on '192.168.0.11'.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_ADMIN.
Error: The remote server returned an error: (401) Unauthorized.
Error count: 1.
Run Code Online (Sandbox Code Playgroud)

我按照上面链接中的说明和我能找到的任何其他文档,几乎都说同样的事情:

  1. 我创建了一个名为kpcpublish的帐户
  2. 我将此帐户添加到名为MSDepSvcUsers的组中- Heck,我甚至将该帐户添加到管理员
  3. 我右键单击该站点并选择Deploy-> Configure Web Deploy Publishing并将kpcpublish添加到列表中.它说如下:

.

Publish enabled for 'SERVER\kpcpublish' Granted 'SERVER\kpcpublish'
full control on 'C:\Website' Successfully created settings file
'C:\Users\Administrator\Desktop\SERVER_kpcpublish_KitchenPC.PublishSettings'
Run Code Online (Sandbox Code Playgroud)

这里必须有一些步骤我失踪,但我想不出有什么能.

更新:

使用computerName属性的完整HTTP路径,我收到错误:

错误代码:ERROR_DESTINATION_NOT_REACHABLE更多信息:无法连接到远程计算机("192.168.0.3").在远程计算机上,确保已安装Web Deploy并且已启动所需的进程("Web管理服务").有关详情,请访问:http: //go.microsoft.com/fwlink/?LinkId = 221672 #ERROR_DES TINATION_NOT_REACHABLE.错误:无法连接到远程服务器错误:连接尝试失败,因为连接方在一段时间后未正确响应,或已建立的连接因为连接的主机未能响应而失败192.168.0.3:8192错误计数:1 .

我已经检查过,Web管理服务确实正在运行.

另一个更新:

我已经完全铺设了系统,并从头开始重新设置.我没有做任何与众不同的事情,只是安装了IIS角色,并确保检查管理工具下的"管理服务",这是WMSVC运行所必需的.然后我安装了Web PI,并安装了"Hosting Providers的推荐配置",它将安装Web Deploy 3.0.但是,我确实注意到安装时出现了错误(我相信我最后一次也遇到了这个错误).看起来像:

在此输入图像描述

我还在这里附加了日志文件.

然后我尝试手动安装Web Deploy 3.0,但它说已经安装了.接下来,我直接从http://www.iis.net/download/webdeploy下载了MSI,并以"修复"模式运行它.这似乎有效.我还注意到WMSVC服务已启动并正在运行.所以这看起来不错.

仍然,MSDeploy将无法连接.我认为这可能是某种防火墙问题,所以我在本地运行它.我尝试过使用HTTPS和HTTP连接.HTTPS给我一个错误,HTTP在2-3分钟后就会超时.

HTTPS:

msdeploy -verb:sync -source:appHostConfig="Default Web Site",computerName=https://STAGING:8172/msdeploy.axd,userName=Administrator,password=Khorf123 -dest:package=c:\DeleteMe.zip
Info: Using ID 'f3a54096-adc4-4f54-9e4f-ad8fde12edb6' for connections to the remote server.
Error Code: ERROR_CERTIFICATE_VALIDATION_FAILED
More Information: Connected to the remote computer ("staging") using the specified process ("Web Management Service"), but could not verify the server's certifi
cate. If you trust the server, connect again and allow untrusted certificates.
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_CERTIFICATE_VALIDATION_FAILED.
Error: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
Error: The remote certificate is invalid according to the validation procedure.
Error count: 1.
Run Code Online (Sandbox Code Playgroud)

HTTP:

msdeploy -verb:sync -source:appHostConfig="Default Web Site",computerName=http://STAGING:8172/msdeploy.axd,userName=Administrator,password=Khorf123 -dest:package=c:\DeleteMe.zip
Info: Using ID 'ebee66f0-08e5-4d9d-98ea-0c2e59784895' for connections to the remote server.
Error: Could not complete the request to remote agent URL 'http://staging:8172/msdeploy.axd'.
Error: The operation has timed out
Error count: 1.
Run Code Online (Sandbox Code Playgroud)

Ric*_*lay 18

(2016-03-07更新 - 注意:非管理员部署也需要?site=IIS_SITE_NAME在之后msdeploy.axd,否则连接将被视为全局并需要管理员访问权限)

不知道最初错过了什么,但你的问题是computerName参数.仅在使用WMSVC时才支持非管理员部署,您需要为其指定完整的URL.

请尝试以下方法

msdeploy -verb:sync ^
  -source:appHostConfig="KitchenPC",computerName=https://192.168.0.3:8172/MsDeploy.axd,userName=kpcpublish,password=secret,authType=Basic ^ 
  -dest:package=c:\DeployTest\KPC.zip 
Run Code Online (Sandbox Code Playgroud)

来自文档:

计算机名称将转换为默认的Web部署URL.例如,computerName = Server1将成为http:// Server1/MsDeployAgentService.如果远程服务使用自定义端口或URL运行,则必须指定完整URL

从安装说明:

如果未安装Web管理服务,MSI将不会安装Web管理服务处理程序组件; 处理程序组件是非管理员部署所必需的

(我找不到更明确的规范来源,将WMSVC描述为非管理员部署的要求)


Mik*_*sen 17

弄清楚了!

因此,似乎(至少在默认情况下),WMSVC只监听HTTPS,而HTTP只会超时.但是,由于我的证书是自签名的,因此我必须使用-allowUntrusted命令行选项.

几乎就够了.我还必须像Richard最初建议的那样指定authType = Basic.因此,将它们放在一起,这是实际工作的MSDeploy命令行:

msdeploy -verb:sync -source:appHostConfig="Default Web Site",computerName=https://192.168.0.3:8172/msdeploy.axd,authType=Basic,userName=Publish,password=secret -dest:package=c:\DeployTest\KPC.zip -allowUntrusted
Run Code Online (Sandbox Code Playgroud)

  • @LukePuplett - 是的,这通常是一个令人沮丧的傍晚让它发挥作用,但是当它发生时它非常光滑!比FTP的文件更好的方式.我最终将它全部包装在PowerShell脚本中,所以我可以说*发布阶段*或*发布prod* (2认同)