Step 1: Login to EC2 instance using SSH and public key
Step 2:add a new user
sudo adduser newuser[newuser name]
Step 3: Switch to the new user
sudo su - newuser[newuser name] -- connect to new user a/c
Step 4: Create a .ssh directory for the authorized_keys file.
mkdir .ssh
Step 5: change the permission of .ssh
chmod 700 .ssh
Step 6: Create a file named "authorized_keys" in the .ssh directory.
touch .ssh/authorized_keys
//or we can user vi editor
Step 7: Change the file permissions of the authorized_keys file to 600 (this means only the file owner can read or write to the file).
chmod 600 .ssh/authorized_keys //this step is very important
Step 8: use ssh-keygen to get the public key for your key pair
ssh-keygen -f username // This command will create 2 files one with .pub extension.
Step 9: Copy the content generated of key.pub to .ssh/authorized_keys and chanage permission of authorized_keys to 600
//careful while copying the contents.
Step 10: Copy the content of another public file to file.pem in your local machine.
//that creates your public ssh key. i.e .pem file.
Step 11: Now you have added a new user to the aws ec2-machine through command and try to connect to the ec2 machine with the new user name and new .pem key.
Note: Do not perform these actions as a root user.
Providing root user / admin user access to newly added user
sudo adduser <username> sudo #for sudo user
sudo adduser <username> admin #for admin user
Step 2:add a new user
sudo adduser newuser[newuser name]
Step 3: Switch to the new user
sudo su - newuser[newuser name] -- connect to new user a/c
Step 4: Create a .ssh directory for the authorized_keys file.
mkdir .ssh
Step 5: change the permission of .ssh
chmod 700 .ssh
Step 6: Create a file named "authorized_keys" in the .ssh directory.
touch .ssh/authorized_keys
//or we can user vi editor
Step 7: Change the file permissions of the authorized_keys file to 600 (this means only the file owner can read or write to the file).
chmod 600 .ssh/authorized_keys //this step is very important
Step 8: use ssh-keygen to get the public key for your key pair
ssh-keygen -f username // This command will create 2 files one with .pub extension.
Step 9: Copy the content generated of key.pub to .ssh/authorized_keys and chanage permission of authorized_keys to 600
//careful while copying the contents.
Step 10: Copy the content of another public file to file.pem in your local machine.
//that creates your public ssh key. i.e .pem file.
Step 11: Now you have added a new user to the aws ec2-machine through command and try to connect to the ec2 machine with the new user name and new .pem key.
Note: Do not perform these actions as a root user.
Providing root user / admin user access to newly added user
sudo adduser <username> sudo #for sudo user
sudo adduser <username> admin #for admin user
No comments:
Post a Comment