快速入门:使用 Azure Stack Hub 门户创建 Linux 服务器 VMQuickstart: Create a Linux server VM by using the Azure Stack Hub portal

可以使用 Azure Stack Hub 门户创建 Ubuntu Server 16.04 LTS 虚拟机 (VM)。You can create an Ubuntu Server 16.04 LTS virtual machine (VM) by using the Azure Stack Hub portal. 在本文中,我们将创建和使用虚拟机。In this article, you create and use a virtual machine. 本文还介绍以下操作:This article also shows you how to:

  • 通过远程客户端连接到 VM。Connect to the VM with a remote client.
  • 安装 NGINX Web 服务器。Install an NGINX web server.
  • 清理资源。Clean up your resources.


本文中的插像已更新,以匹配 Azure Stack Hub 版本 1808 中引入的更改。The images in this article are updated to match changes that were introduced in Azure Stack Hub version 1808. 除了非托管磁盘外,版本 1808 还添加了对使用 托管磁盘 的支持。Version 1808 adds support for using managed disks in addition to unmanaged disks. 如果使用较早的版本,某些任务图像(例如磁盘选择)与 UI 中显示的内容不同。If you're using an earlier version, images for some tasks, such as disk selection, differ from what's displayed in your UI.


  • Azure Stack Hub 市场中的 Linux 映像A Linux image in the Azure Stack Hub Marketplace

    默认情况下,Azure Stack Hub 市场中没有 Linux 映像。The Azure Stack Hub Marketplace, by default, doesn't have a Linux image. 请让 Azure Stack Hub 操作员提供所需的 Ubuntu Server 16.04 LTS 映像。Have the Azure Stack Hub operator provide the Ubuntu Server 16.04 LTS image you need. 操作员可以使用将市场项从 Azure 下载到 Azure Stack Hub 中的说明。The operator can use the instructions in Download Marketplace items from Azure to Azure Stack Hub.

  • 可以访问 SSH 客户端Access to an SSH client

    如果你使用 Azure Stack 开发工具包 (ASDK),可能无法访问安全外壳 (SSH) 客户端。If you're using the Azure Stack Development Kit (ASDK), you might not have access to a Secure Shell (SSH) client. 如果需要客户端,有多个包含 SSH 客户端的包可供使用。If you need a client, several packages include an SSH client. 例如,PuTTY 包含 SSH 客户端和 SSH 密钥生成器 (puttygen.exe)。For example, PuTTY includes an SSH client and SSH Key Generator (puttygen.exe). 有关可用包的详细信息,请参阅如何使用 SSH 公钥For more information about available packages, see How to use an SSH public key.

  • 本快速入门使用 PuTTY 生成 SSH 密钥并连接到 Linux 服务器 VM。This quickstart uses PuTTY to generate the SSH keys and to connect to the Linux server VM. 下载并安装 PuTTYDownload and install PuTTY.

创建 SSH 密钥对Create an SSH key pair

需要一个 SSH 密钥对来完成本文中的所有步骤。To finish all the steps in this article, you need an SSH key pair. 如果已有一个 SSH 密钥对,则可以跳过此步骤。If you already have an SSH key pair, you can skip this step.

若要创建 SSH 密钥对:To create an SSH key pair:

  1. 转到 PuTTY 安装文件夹(默认位置为 C:\Program Files\PuTTY )并运行:Go to the PuTTY installation folder (the default location is C:\Program Files\PuTTY ) and run:


  2. 在“PuTTY 密钥生成器”窗口中,将“要生成的密钥类型”设置为 RSA ,并将“所生成密钥中的位数”设置为 2048In the PuTTY Key Generator window, set Type of key to generate to RSA , and set Number of bits in a generated key to 2048.

    PuTTY 密钥生成器配置

  3. 然后选择“生成” 。Select Generate.

  4. 若要生成密钥,请在“密钥”框中随机移动指针。 To generate a key, in the Key box, move the pointer randomly.

  5. 完成密钥生成过程后,选择“保存公钥”和“保存私钥”来将密钥保存到文件中。 When the key generation has finished, select Save public key , and then select Save private key to save your keys to files.

    PuTTY 密钥生成器结果

登录到 Azure Stack Hub 门户Sign in to the Azure Stack Hub portal

Azure Stack Hub 门户的地址取决于要连接到的 Azure Stack Hub 产品:The address of the Azure Stack Hub portal depends on which Azure Stack Hub product you're connecting to:

  • 对于 ASDK,请转到 https://portal.local.azurestack.externalFor the ASDK, go to https://portal.local.azurestack.external.

  • 对于 Azure Stack Hub 集成系统,请转到 Azure Stack Hub 操作员提供的 URL。For an Azure Stack Hub integrated system, go to the URL that your Azure Stack Hub operator provided.

创建 VMCreate the VM

  1. 选择“创建资源” > “计算” 。Select Create a resource > Compute. 搜索 Ubuntu Server 16.04 LTSSearch for Ubuntu Server 16.04 LTS. 选择名称。Select the name.

    创建 Linux 服务器

  2. 选择“创建” 。Select Create.

    创建 Linux 服务器 - 创建

  3. 输入 VM 信息。Enter the VM information. 为“身份验证类型”选择“SSH 公钥”,粘贴保存的 SSH 公钥,然后选择“确定”。 Select SSH public key for Authentication type, and paste the SSH public key that you saved, and then select OK.


    请确保删除密钥中的所有前导和尾随空格。Make sure that you remove any leading or trailing white space for the key.


  4. 为“VM 大小”选择“D1_v2”。 Select D1_v2 for the VM size.


如果要创建已启用 GPU 的 VM,请选择 "GPU VM NC_v3 " 或 " NC4AS_T4_V3 " 作为 vm 大小。If you are creating a GPU enabled VM, select GPU VM NC_v3 or NC4as_T4_v3 for the VM size.

创建 Linux 服务器-大小

  1. 在 " 设置 " 边栏选项卡上,输入对默认值所做的更改,并使用托管磁盘。Enter your changes to the defaults on the Settings blade, Use Managed disks. 如果需要允许 SSH 访问,请选择 " ssh (22) 打开端口。If you need to allow SSH access, select SSH (22) to open the port. 配置准备就绪后,选择 "确定"When your configurations are ready, select OK.

    创建 Linux 服务器-设置

  2. 在摘要中选择 "确定" 以启动 VM 部署。Select OK in the Summary to start the VM deployment. 选择 " 虚拟机 " 以查看新 vm,搜索 vm 名称,然后在搜索结果中选择 vm。Select Virtual Machines to see your new VM, search for the VM name, and then select the VM in the search results.

创建 Linux 服务器-摘要

连接到 VMConnect to the VM

  1. 在 VM 页上选择“连接”。Select Connect on the VM page. 可在该页上看到连接到 VM 时所需的 SSH 连接字符串。You can find the SSH connection string that you need to connect to the VM.

  2. 在“PuTTY 配置”页的“类别”窗格中,向下滚动并展开“SSH”,然后选择“身份验证”。On the PuTTY Configuration page, in the Category pane, scroll down to and expand SSH , and then select Auth.

    连接 VM

  3. 选择“浏览”,然后选择保存的私钥文件。Select Browse , and then select the private key file that you saved.

  4. 在“类别”窗格中,向上滚动并选择“会话”。In the Category pane, scroll up to and select Session.

  5. 在 " 主机名 (或 IP 地址) " 框中,粘贴 Azure Stack 集线器门户中显示的连接字符串。In the Host Name (or IP address) box, paste the connection string that's shown in the Azure Stack Hub portal. 在此示例中,字符串为 asadmin@ this example, the string is asadmin@

  6. 选择“打开”以打开 VM 的会话。Select Open to open a session for the VM.

    Linux 会话

安装 NGINX Web 服务器Install the NGINX web server

若要更新包源并在 VM 上安装最新的 NGINX 包,请输入以下 bash 命令:To update package sources and install the latest NGINX package on the VM, enter the following bash commands:


# update package source
sudo apt-get -y update

# install NGINX
sudo apt-get -y install nginx

完成安装 NGINX 后,请关闭 SSH 会话,并在 Azure Stack 中心门户中打开 "VM 概述 " 页。When you finish installing NGINX, close the SSH session and open the VM Overview page in the Azure Stack Hub portal.

为 Web 流量打开端口 80Open port 80 for web traffic

网络安全组 (NSG) 保护入站和出站流量的安全。A network security group (NSG) secures inbound and outbound traffic. 在 Azure Stack 中心门户中创建 VM 时,将在 SSH 连接的端口22上创建入站规则。When a VM is created in the Azure Stack Hub portal, an inbound rule is created on port 22 for SSH connections. 由于此 VM 托管着 Web 服务器,因此需要创建一个 NSG 规则来允许端口 80 上的 Web 流量。Because this VM hosts a web server, an NSG rule needs to be created to allow web traffic on port 80.

  1. 在 VM 的“概述”页上,选择 资源组 的名称。On the VM Overview page, select the name of the Resource group.

  2. 选择 VM 的 网络安全组Select the network security group for the VM. 可以使用“类型”列来识别 NSG。You can identify the NSG by using the Type column.

  3. 在左窗格中的“设置”下,选择“入站安全规则”。In the left pane, under Settings , select Inbound security rules.

  4. 选择 添加Select Add.

  5. 在“名称”框中键入 httpIn the Name box, type http.

  6. 请确保将“端口范围”设置为 80,将“操作”设置为“允许”。Make sure that Port range is set to 80 and Action is set to Allow.

  7. 选择“确定” 。Select OK.

查看“欢迎使用 nginx”页View the Welcome to nginx page

在 VM 上安装 NGINX 并打开端口 80 后,可通过 VM 的公共 IP 地址访问 Web 服务器。With NGINX installed and port 80 open on your VM, you can access the web server by using the VM's public IP address. (该公共 IP 地址显示在 VM 的“概述”页上。)(The public IP address is shown on the VM's Overview page.)

打开 web 浏览器,并中转到 http:// <public IP address>Open a web browser, and go to http://<public IP address>.

NGINX Web 服务器欢迎页

清理资源Clean up resources

清理不再需要的资源。Clean up the resources that you don't need any longer. 若要删除 VM 及其资源,请在 VM 页上选择资源组,然后选择“删除”。To delete the VM and its resources, select the resource group on the VM page, and then select Delete.

后续步骤Next steps

在本快速入门中,你已部署了一个带有 Web 服务器的基本 Linux 服务器 VM。In this quickstart, you deployed a basic Linux server VM with a web server. 若要了解 Azure Stack VM Hub 的详细信息,请继续阅读 Azure Stack Hub 中 VM 的注意事项To learn more about Azure Stack Hub VMs, continue to Considerations for VMs in Azure Stack Hub.