How to Create SSH user with & without key on AWS EC2 instance.

SSH (Secure Shell) is a network protocol that enables secure remote connections between two systems. System admins use SSH utilities to manage machines, copy, or move files between systems. Because SSH transmits data over encrypted channels, security is at a high level.

We can create SSH user with Key & without key.

SSH User with Key:

             useradd -m -d /home/newuser -s /bin/bash newuser


Fig 1


  • Go to newuser directory.

   cd /home/newuser

  • Create a ssh key.


Then set the path of ssh key where key wiil create like /home/newuser/example & Press Enter.(Provide the key name in place of example).

Fig 2


  • Change the name of example instead of

     mv example

  • Make a folder with name .ssh .

     mkdir .ssh

  •  Move the content of to .ssh/authorized_keys.

     cat >> .ssh/authorized_keys

Fig. 3


• Now provide the follwoing permissions.

   chmod 600 .ssh/authorized_keys

  chown newuser:newuser -R .ssh

  chmod 0700 .ssh

Fig. 4


SSH user without Key:

  • Login to ec2 instance with sudo privilege.
  • Now create a newuser.Mention the name of user in place of user-name.

          useradd user-name

  • Set the password.

         passwd user-name 


Fig. 6


  • Open the sshd_config file.

   vim /etc/ssh/sshd_config

  • Search & Enable the PasswordAuthentication(Public Key authentication).By default, PasswordAuthentication is disable.

          PasswordAuthentication yes


Fig. 7


  • Then restart the ssh.service .

          systemctl restart ssh.service


Leave a Reply