通过CLI配置azure linux vm时创建多个用户 [英] creating more than one user while provisioning azure linux vm via CLI

查看:81
本文介绍了通过CLI配置azure linux vm时创建多个用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过terraform在azure上创建一个Linux虚拟机,我的要求是在操作系统上设置多个用户帐户。我对Azure Cloud比较新,并且经历了一些基本的文档,但找不到我想要的东西。


我可以使用az vm扩展集和在配置vm后添加用户的ssh-keys,但我正在寻找创建新用户的选项,并在创建实例时推送他们的密钥。我还想提取所有用户信息
和他们的公共ssh-key。


我想通过terraform或shell脚本来利用自动化流程of   azure-cli
如果任何人有任何与我的用例相关的信息,或者指出任何其他方式来完成这项任务,那么我将非常感激。


谢谢

解决方案

嗨opensourceJunkie,


感谢您的光临!您可以使用称为cloud-init的方式在实例创建时实现多个用户的设置。以下是相同的文档:


https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cloudinit-add-user


https://docs.microsoft.com/en-us/azure/virtual-machines/linux / using-cloud-init


如果您希望每次配置VM时都创建相同的用户,您还可以使用自定义映像:


1。创建VM


2。使用  az vm扩展程序集


3添加用户。创建自定义图片 


4。使用创建的自定义映像创建新VM


https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-custom-images


为了获取有关用户及其公共ssh密钥的信息,您可以使用Run Command:


https://docs.microsoft.com/en-us/azure/virtual-machines/linux/run-command


<希望这有帮助!


I'm trying to create a Linux virtual machine on azure via terraform and my requirement is to setup multiple user accounts on OS. I'm relatively new to Azure Cloud and went through some basic documentation but couldn't find what i was looking for.

I could make use of az vm extension set and add users with their ssh-keys after provisioning the vm but i'm looking for option to create new user and push their keys at the time of instance creation. I would also like to pull all user information and their public ssh-keys.

I want to automate the process either via terraform or shell scripting by taking advantage of azure-cli. If anybody has anything relevant to my use case or point me towards direction for any alternative way to achieve this task then that would be much appreciated.

Thanks

解决方案

Hi opensourceJunkie,

Thank you for reaching out! You can achieve the setup of multiple users at the time of instance creation using something known as cloud-init. Here is the documentation for the same:

https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cloudinit-add-user

https://docs.microsoft.com/en-us/azure/virtual-machines/linux/using-cloud-init

If you are looking to create the same users every time you provision the VM, you can also make use of a custom images:

1. Create a VM

2. Add the users using az vm extension set

3. Create a custom image 

4. Use the created custom image to create new VMs

https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-custom-images

In order to fetch the information about the users and their public ssh keys, you can make use of Run Command:

https://docs.microsoft.com/en-us/azure/virtual-machines/linux/run-command

Hope this helps!


这篇关于通过CLI配置azure linux vm时创建多个用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆