標籤:windows azure下的windows vm密碼重設
Windows azure下的windows vm密碼重設
說到密碼問題,相信管理員都頭疼,尤其作為一個大企業的管理員,伺服器密碼的使用很是麻煩,為什麼這麼說呢,因為大企業要求的資訊安全,要求使用者密碼45天更改一次,當然不更改的話那就意味著到期,就無法使用了,還有一種情況那就是使用者的密碼,對於不在公司辦公,而是外派的使用者不經常訪問偶爾訪問公司的資訊系統的使用者密碼確實是一個問題,對於我們公司來說,就這樣的問題比較多,經常讓助理髮郵件給管理員重設他們的密碼,這樣給管理員帶來很大困擾,後來呢,為了徹底解決該問題,就做了一個驗證系統,綁定使用者的私人資訊讓使用者自己重設密碼,這樣就減少了管理員的日常工作壓來。而今天呢,我們主要介紹在windows azure下建立windows vm後如果密碼忘記了如何重設,因為在windows azure上建立vm後是無法通過consloe去掛載破解密碼鏡像來破解密碼,當然微軟肯定會將該問題考慮在內的,就通過powershell來重設密碼,具體操作見下:
密碼忘記有兩種方式,一種是知道需要重設的賬戶密碼,一一種是不知道需要重設的密碼。比如上屆管理員建立完後工作沒交接就走了,本屆管理員不知道密碼,不知道重設那個密碼,所以windows azure就用覆蓋的方法來完成從重設密碼操作。
首先明確的是windows azure的poral頁面沒有密碼相關的重設選項,所以需要用windows azure powershell來完成,再次我們就不多介紹如何下載windows azure pwoershell及安裝。我們已經提前安裝好了,關於下載及安裝windows azure powershell的方法我們已在前面的文章介紹了,可以參考上篇文章。
我們都知道,windows 8系統以後都是預設安裝了windows powershell組件的,只需要啟用該服務即可。具體也不多介紹了。我本次的實驗是windows 2008R2作業系統,所以系統也是預設安裝的,我們下載了windows azure powershel,那windows azure poershell跟系統內建的windows powershell有什麼區別呢,最大的區別就是有沒有azure相關的服務模組
區別:安裝路勁都是不同的
650) this.width=650;" title="clip_image002" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image002" src="http://s3.51cto.com/wyfs02/M01/53/E4/wKioL1RzPibhmzw3AAFybA825Mo228.jpg" height="279" />
建立Windows vm
650) this.width=650;" title="clip_image004" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image004" src="http://s3.51cto.com/wyfs02/M01/53/E6/wKiom1RzPaejqjY0AAEQIcGKnl4567.jpg" height="305" />
填寫 虛擬機器的相關資訊
650) this.width=650;" title="clip_image006" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image006" src="http://s3.51cto.com/wyfs02/M02/53/E6/wKiom1RzPafB7tWyAADRnTqNWbE251.jpg" height="310" />
開始建立
650) this.width=650;" title="clip_image008" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image008" src="http://s3.51cto.com/wyfs02/M00/53/E6/wKiom1RzPafBvFpyAADAQkCjXJ0877.jpg" height="282" />
建立完成後,我們就可以遠端桌面登陸了。
登陸後我們查看使用者和組的相關資訊,發現系統沒有administrator使用者及許可權。
650) this.width=650;" title="clip_image010" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image010" src="http://s3.51cto.com/wyfs02/M01/53/E6/wKiom1RzPaeCGiZaAAEBjkGures081.jpg" height="385" />
接下來我們需要安裝windows azure powershell來管理:
因為windows azure的poral頁面沒有密碼相關的重設選項,所以需要用windows azure powershell來完成,再次我們就不多介紹如何下載windows azure pwoershell及安裝。我們已經提前安裝好了,關於下載及安裝windows azure powershell的方法我們已在前面的文章介紹了,可以參考上篇文章。
我們都知道,windows 8系統以後都是預設安裝了windows powershell組件的,只需要啟用該服務即可。具體也不多介紹了。我本次的實驗是windows 2008R2作業系統,所以系統也是預設安裝的,我們下載了windows azure powershel,那windows azure poershell跟系統內建的windows powershell有什麼區別呢,最大的區別就是有沒有azure相關的服務模組,再次也不多介紹了,有了powershell 後,我們需要windows azure的訂閱檔案,我們需要通過訪問windows azure的portal介面進行下載或者通過powershell下載。
https://manage.windowsazure.cn/publishsettings/index?client=powershell
650) this.width=650;" title="clip_image012" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image012" src="http://s3.51cto.com/wyfs02/M01/53/E4/wKioL1RzPibT6xdJAAEXDjlx8vQ786.jpg" height="340" />
環境準備好之後,我們就開始工作了
650) this.width=650;" title="clip_image014" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image014" src="http://s3.51cto.com/wyfs02/M00/53/E4/wKioL1RzPibxjVisAAD5Kwz_KWg349.jpg" height="356" />
開始是匯入訂閱檔案:
Import-azurepublishSettingFile ‘d:xxxxx.publishseetingfiles’
650) this.width=650;" title="clip_image016" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image016" src="http://s3.51cto.com/wyfs02/M01/53/E4/wKioL1RzPieDV4baAAD8KZ4egr0709.jpg" height="353" />
匯入完成,會顯示當前的所有訂閱檔案。
650) this.width=650;" title="clip_image018" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image018" src="http://s3.51cto.com/wyfs02/M02/53/E4/wKioL1RzPieAXeAnAAFpUKtsQXI016.jpg" height="349" />
因為我環境下有多個訂閱,所以我們需要設定預設的訂閱
650) this.width=650;" title="clip_image020" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image020" src="http://s3.51cto.com/wyfs02/M00/53/E4/wKioL1RzPiexZJE9AAGKWTqllBI917.jpg" height="357" />
檢查Azure PowerShell中預設的Azure賬戶是不是自己想要操作的賬戶:
輸入命令:Get-AzureSubscription –Default,檢查出來的結果中會出現Subscription ID,查看一下這個Sub ID是否是自己Azure管理平台上的訂閱ID.
如果Sub ID不同,那麼需要重新設定預設賬戶(如果您是首次操作,那麼應該會是相同的)。更改命令:
Select- Select-AzureSubscription -SubscriptionName "添加賬戶名" -Default
650) this.width=650;" title="clip_image022" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image022" src="http://s3.51cto.com/wyfs02/M02/53/E4/wKioL1RzPieSAd9nAACErBLGXV8272.jpg" height="116" />
註:如果一個訂閱檔案下有多個訂閱id的話,我們也可以選擇修改指定的訂閱id為預設
650) this.width=650;" title="clip_image024" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image024" src="http://s3.51cto.com/wyfs02/M01/53/E4/wKioL1RzPiexsmOUAACafIwh1hw665.jpg" height="118" />
修改後,我們輸入命令
Get-AzureVM
(查到自己的虛擬機器名稱及雲端服務名稱)
650) this.width=650;" title="clip_image026" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image026" src="http://s3.51cto.com/wyfs02/M02/53/E4/wKioL1RzPifz46ALAACzL-bhvGA595.jpg" height="277" />
輸入命令
$VM1 = Get-AzureVM -ServiceName "xxxx" -Name "mxxx"
定義一個變數vm1,然後查看當前服務的資訊
650) this.width=650;" title="clip_image028" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image028" src="http://s3.51cto.com/wyfs02/M00/53/E4/wKioL1RzPifD_jl-AACUqCL6_Rc530.jpg" height="216" />
輸入命令
$VM1.VM.ProvisionGuestAgent
(查看輸出結果是否是‘True’)
如果虛擬機器安裝代理了,顯示的記過為true,如果沒有安裝agent的話,顯示false
一般虛擬機器都預設會在建立的時候安裝代理
650) this.width=650;" title="clip_image030" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image030" src="http://s3.51cto.com/wyfs02/M01/53/E4/wKioL1RzPifTQiCSAACfCp7pPZc277.jpg" height="265" />
如果是‘True’那麼您就可以進行如下操作來修改虛擬機器的使用者名稱和密碼:
輸入命令:
Set-AzureVMaccessExtension -VM $VM1 –UserName "AdminAccountName" –Password "NewPassword" | Update-AzureVM
註:如果username是之前建立的使用者,那就會直接重設新密碼,如果是忘記之前建立的使用者名稱話,再次會將之前的使用者名稱重新命名及設定新密碼
我之前系統中的賬戶是gavin,我如果忘記之前的使用者是gavin,我在此輸入新的使用者及新密碼會將我之前的使用者及密碼覆蓋。
650) this.width=650;" title="clip_image032" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image032" src="http://s3.51cto.com/wyfs02/M02/53/E4/wKioL1RzPifzHOxcAAD-9tgACXw495.jpg" height="275" />
操作完成後,我們登陸伺服器器查看:
650) this.width=650;" title="clip_image034" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image034" src="http://s3.51cto.com/wyfs02/M00/53/E4/wKioL1RzPijjP0RKAAEW_gEcWCA855.jpg" height="396" />
650) this.width=650;" title="clip_image036" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image036" src="http://s3.51cto.com/wyfs02/M01/53/E4/wKioL1RzPiiQGTaKAAEMwdN2NgU978.jpg" height="352" />
操作完成。
以上單獨執行的代碼我們可以寫到一個.pst1的檔案,前提是確認條件滿足,然後在執行該檔案:
$VM1 = Get-AzureVM -ServiceName "miyaw2008" -Name "miyaw2008"Set-AzureVMaccessExtension -VM $VM1 –UserName "AdminAccountName" –Password "NewPassword" | Update-AzureVM
650) this.width=650;" title="clip_image038" style="border-top:0px;border-right:0px;background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px;" border="0" alt="clip_image038" src="http://s3.51cto.com/wyfs02/M02/53/E4/wKioL1RzPiigXQS6AABQEK_zC9c384.jpg" height="118" />
本文出自 “高文龍” 部落格,請務必保留此出處http://gaowenlong.blog.51cto.com/451336/1582175
Windows Azure下的Windows VM密碼重設