This article photo 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) Run $ssh-keygen-y on the local Terminla when prompted to enter the file where the key is located. Please specify the path to your. Pem file, such as/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 remote server with the initial account. If the EC2 instance system is Ubuntu, the local terminal runs: $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 obtained in step 1 to the file to save the exit. 3. Test whether you can sign in to AWS at the last exit of Step 2 (two times) with the new account until you exit AWS and return to local. Run: $ssh-i YOURPRIVATEKEY.PEM [email protected] assume success. The above configuration takes effect. 4. (Optional) Disable password login # vi/etc/ssh/sshd_configpasswordauthentication no# service ssh restart. SSH stop/waiting. SSH start/running, Process 7262
Aamazon Web Service EC2 Ubuntu New user and SSH connection host