Asp.net

MSDeploy.exe 可以以管理員身份連接,但不能以任何其他 Windows 帳戶連接

  • April 13, 2016

我正在將 MSDeploy 集成到我的建構過程中,並且在進行身份驗證時遇到了問題。以下命令工作正常:

msdeploy -verb:sync -source:appHostConfig="KitchenPC",computerName=192.168.0.3,userName=Administrator,password=secret -dest:package=c:\DeployTest\KPC.zip

但是,這不起作用:

msdeploy -verb:sync -source:appHostConfig="KitchenPC",computerName=192.168.0.3,userName=kpcpublish,password=secret -dest:package=c:\DeployTest\KPC.zip

並產生錯誤:

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.

我已按照上面連結中的說明以及我能找到的任何其他文件進行操作,它們幾乎都說同樣的話:

  1. 我創建了一個名為kpcpublish的帳戶
  2. 我將此帳戶添加到名為MSDepSvcUsers的組中- 哎呀,我什至將該帳戶添加到管理員
  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'

必須缺少一些步驟,但我無法弄清楚可能是什麼。

更新:

使用該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,並安裝了“託管服務提供商的推薦配置”,它將安裝 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.

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.

更新於 2016-03-07 - 注意:非管理員部署也需要?site=IIS_SITE_NAMEafter 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 

從文件

電腦名稱將轉換為預設的 Web 部署 URL。例如,computerName=Server1將變為**<http://Server1/MsDeployAgentService>**。如果遠端服務使用自定義埠或 URL 執行,則必須指定完整 URL

根據安裝說明

如果未安裝 Web 管理服務,MSI 將不會安裝 Web 管理服務處理程序組件;處理程序組件對於非管理員部署是必需的

(我找不到更明確的規範來源將 WMSVC 描述為非管理員部署的要求)

引用自:https://stackoverflow.com/questions/12984960