Add new SSH users to AWS EC2

  • Check existing users : cut -d: -f1 /etc/passwd
  • sudo adduser user_name
  • add newly created to root group sudo usermod -a -G sudo user_name
  • change current user to new user
  • cd to home dir of newly created user
  • run mkdir .ssh
  • secure it by chmod 700 .ssh
  • to create authorized_keys file run touch .ssh/authorized_keys
  • Copy your public key in clipboard
  • cat >> .ssh/authorized_keys
  • Paste key and hit enter save file
  • Now from client machine try to connect server ex. ssh private_key_path username@domainorip