Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of using instance custom script and custom instance administrator account

Shulou Source: shulou.com Published: 2022-06-02 04:30:17 09月22日 Update

Editor to share with you the use of example custom scripts and custom instance administrator account methods, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article. Let's learn about it!

The administrator account of the custom instance

Instance customization script is a custom instance startup script provided by Aliyun ECS for users. For more information, please see Aliyun online help document: instance Custom data.

This document takes the Linux instance as an example to show how you should use the instance custom script to customize the administrator account of the instance when creating the instance. You can also use scripts to customize the administrator account of the Windows instance.

Scene

When purchasing an ECS instance, you need to use the instance custom script if you want to achieve the following results.

Do not use the root user that comes with the ECS instance by default as the administrator. You can customize the specific disable method and degree in the instance custom script.

Create a new administrator account and customize the user name.

The newly created administrator account only uses the SSH key pair for remote login when managing the instance, not the user password.

If the user needs to take actions related to administrator privileges, he or she can use sudo to elevate rights without a password.

Configuration method

You can follow these steps to achieve the above scenario requirements.

Log in to the Aliyun ECS console and create an instance with the following configuration:

Network type: VPC network

Instance specification: an example optimized by Imax O

Images: CentOS 7.2 of public images

Enter the following in the custom data entry box of the create page:

#! / bin/shuseradd testecho "test ALL= (ALL) NOPASSWD:ALL" | tee-a / etc/sudoersmkdir / home/test/.sshtouch / home/test/.ssh/authorized_keysecho ssh-rsa

Note:

The first line must be #! / bin/sh, with no spaces before it.

There should be no extra spaces and enter in the full text.

The key of the last line is your public key, which you can customize.

If you need to make other configurations, you can add them directly in the script.

The sample script is limited to CentOS 7.2 images. Other images should be customized and modified according to the operating system type.

Select Post-creation Settings in Security Settings.

After completing the above configuration, click Buy now, and follow the instructions on the page to activate the instance.

After the instance is purchased, you can log in to the instance using the custom test user through the SSH private key. You can also use sudo to elevate rights and perform various operations that require administrator permissions, as shown in the example in the figure.

The above is all the contents of the method of using the instance custom script and the custom instance administrator account, thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Instance administration administrator script account user image configuration method content Ali login line scenario password key data permissions examples spaces Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple vpn NVidia Shulou Information