Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report