Sunday, September 13, 2015

Create User for Ec2 Instance

For CentoS

From root access user press below command

adduser username
passwd username
visudo
cd /home/username/

su username

ssh-keygen -b 1024 -f username -t dsa
mkdir .ssh
chmod -Rv 700 .ssh/
cat username.pub > .ssh/authorized_keys
chmod -Rv 600 .ssh/authorized_keys
chown username:ec2-user .ssh

Now pass pem file to user.

For Ubuntu

Managing User Accounts on Your Linux Instance

[ec2-user ~]$ sudo adduser newuser

[ec2-user ~]$ sudo su - newuser

[newuser ~]$ mkdir .ssh

[newuser ~]$ chmod 700 .ssh

[newuser ~]$ touch .ssh/authorized_keys

[newuser ~]$ chmod 600 .ssh/authorized_keys

Edit the authorized_keys file with your favorite text editor and paste the public key for your key pair (pem file open in puttygen and pase ppk file into the file

[newuser ~]$ sudo su

[ec2-user ~]$  vi /etc/sudoers.d/90-cloudimg-ubuntu

newuser ALL=(ALL) NOPASSWD:ALL

[ec2-user ~]$ sudo userdel -r olduser

0 comments:

Post a Comment