简体   繁体   中英

Add user while instance creation in google cloud

I want to create users in windows server on google cloud during instance creation. Searched in google cloud documentation and other sites but could not find answers. I am aware of startup scripts but those are great when you want to do something every time machine boots up. Please help.

You can use GCP startup script to do it. Please have a look at the documentation Running startup scripts . For example, you can easily add a user John and add him to the group Remote Desktop Users by using metadata :

元数据

and, as a result, you'll be able to login via RDP to your VM instance with login John and password fadf24as.FD* .

By default such script will be executed during each start cycle of VM instance:

Compute Engine lets you create and run your own startup scripts on your virtual machine (VM) instances to perform automated tasks every time your instance boots up .

To change this default behavior you can add there additional step like creating some folder or file and use them as a flag: if folder or file already exist than rest part of the script should be skipped. In such case PowerShell looks more suitable than cmd , final script could be uploaded from Google Cloud Bucket .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM