练习 - 测试新虚拟机

已完成

创建虚拟机时,系统会向其分配一个可通过 Internet 访问的公共 IP 地址和一个在 Azure 数据中心内使用的专用 IP 地址。 这两个值都显示在 create 命令返回的 JSON 块中,如下所示:

{
   ...
  "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.

然后会出现一个远程 shell,可供输入 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 以注销虚拟机。