練習 - 測試您的新虛擬機器

已完成

當您建立虛擬機器時,其會獲指派可透過網際網路連線的公用 IP 位址,以及在 Azure 資料中心內使用的私人 IP 位址。 這兩個值都會出現在命令傳回的 JSON 區塊 create 中,如下所示:

{
   ...
  "privateIpAddress": "10.0.0.4",
  "publicIpAddress": "40.83.165.85",
   ...
}

使用 SSH 來連線至 VM

我們可以在安全殼層 (ssh) 工具中使用公用 IP 位址,快速測試 Linux VM 是否已啟動且在執行中。 請記住,我們已將系統管理員名稱設定為 azureuser,因此我們必須指定該名稱。 請務必使用來自「您的」執行中執行個體的公用 IP 位址。

ssh azureuser@<public-ip-address>

注意

我們不需要密碼,因為我們在建立 VM 時已產生 SSH 金鑰組。 當您第一次使用殼層連線到 VM 時,將收到提示要求您確認主機的真確性。

這是因為我們嘗試直接存取 IP 位址,而不是透過主機名稱。 回答「是」會將 IP 位址儲存為連線的有效主機,並允許繼續進行連線。

The authenticity of host '40.83.165.85 (40.83.165.85)' can't be established.
RSA key fingerprint is SHA256:hlFnTCAzgWVFiMxHK194I2ap6+5hZoj9ex8+/hoM7rE.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '40.83.165.85' (RSA) to the list of known hosts.

然後您將會看到遠端殼層,您可以在其中輸入 Linux 命令。

Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 5.0.0-1014-azure x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Wed Aug 21 20:32:04 UTC 2019

  System load:  0.0               Processes:           108
  Usage of /:   4.2% of 28.90GB   Users logged in:     0
  Memory usage: 9%                IP address for eth0: 10.0.0.5
  Swap usage:   0%

0 packages can be updated.
0 updates are security updates.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

azureuser@SampleVM:~$

嘗試一些命令,例如 psls 來進行練習。 當您完成時,請輸入 exitlogout 來登出虛擬機器。