This article refers to Http://docs.aws.amazon.com/zh_cn/AWSEC2/latest/UserGuide/managing-users.htmlhttp://docs.aws.amazon.com/zh_ Cn/awsec2/latest/userguide/ec2-key-pairs.html#retrieving-the-public-key1. Obtaining a public key by key pair (KeyPair) In the local Terminla execution $ssh-keygen-y when prompted for the file where the key is located, specify the path to your. Pem file, for example/PATH_TO_KEY_PAIR/MY-KEY-PAIR.PEM the command will return a public key: such as Ssh-rsa aaaab3nzac1yc2eaaaadaqabaaabaqclksfknkusevgj3eyhce53pcjqp3maahdfcvbs7o6vhz2itxcih+pndsuaw+wnqn/mzphtk/a/ gu8jezoowbkm4yxyb/wb96xbifvesfjuop/d6rjhjoi0ibxrlslnbitntckij7fbtxjmxlvvwjryduilbmtjytwb+qhyxumozce5pjz5/ i8sejtjnv3iaog/cqk+0fzzqaejaahco+cy/5wrubkrhmfjr6hcxkvjdwpkyqs3xqc0+fmuzofz221cbt5imucxxpkx4rwi+ Z7wb3rbbqoqzd8v7yeb7ozlpnwoyn0qfu0xa246ra8qfyicnywi3f05p6klxexample2. Then ssh the remote server with the initial account. If the EC2 instance system is Ubuntu, the local terminal executes: $ssh-i YOURPRIVATEKEY.PEM [email protected] New User$adduser NewUser switch to NewUser and then configure the public key $sudo Su-newuser$mkdir. Ssh$chmod. Ssh$touch Authorized_keys Open Editor Editor. Ssh/authorized_keys add the public key that you obtained in step 1 to the file to save the exit. 3. TestingCan you sign in to AWS at the last exit of Step 2 (which should be two times) with the new account until you exit AWS and return to local. Execution: $ssh-i YOURPRIVATEKEY.PEM [email protected] If successful, the above configuration will take effect.
Aamazon Web Service EC2 Create a new user and connect to host with SSH