How to configure ssh password on AWS

How to configure an ssh password between nodes in an AWS cluster

+4
source share
3 answers

The following steps for setting a password with less authentication have been thoroughly tested for Centos and Ubuntu.

Assumptions:

  • You already have access to your EC2 machine. The pem key may be used, or you have credentials for a unix user who has root privileges.
  • You already have RSA keys installed on your local computer. The private key and public key are available on "~ / .ssh / id_rsa" and "~ / .ssh / id_rsa.pub" respectively.

Steps:

  • Log in to EC2 as root.
  • Create a new user

    useradd -m <yourname> sudo su <yourname> cd mkdir -p ~/.ssh touch ~/.ssh/authorized_keys 

    Add the contents of the ~ / .ssh / id_rsa.pub file on the local computer to ~ / .ssh / authorized_keys on the EC2 machine.

     chmod -R 700 ~/.ssh chmod 600 ~/.ssh/* 
  • Make sure the device is sshing enabled. In the / etc / ssh / sshd _config file, verify that the line containing "PasswordAuthentication yes" is uncommented. Restart the sshd service if you make any changes to this file:

     service sshd restart # On Centos service ssh restart # On Ubuntu 
  • Now your login without a password should work. Try the following steps on your local computer:

     ssh -A <yourname>@ec2-xx-xx-xxx-xxx.ap-southeast-1.compute.amazonaws.com 
  • Make yourself superuser. Open /etc/sudoers . Make sure the following two lines are uncommented:

     ## Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL ## Same thing without a password %wheel ALL=(ALL) NOPASSWD: ALL 

    Add yourself to the wheel group.

     usermod -aG wheel <yourname> 
+4
source

It may help someone

Copy the pem file on the machine, then copy the contents of the pem file to the .ssh / id_rsa file, which you can use with the command below or your own

 cat my.pem > ~/.ssh/id_rsa 

try ssh localhost, it should work with other machines in the cluster

+3
source

you can use ssh keys as described here: http://pkeck.myweb.uga.edu/ssh/

-5
source

Source: https://habr.com/ru/post/1334202/


All Articles