Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create a new user to SFTP into an AWS EC2 Server
Create User
------------
sudo adduser <new user> && sudo su - <new user> && cd /home/<new user>
Create SSH
----------
mkdir .ssh && chmod 700 .ssh && touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
ssh-keygen -f <new user> && cat <new user>.pub >> /home/<new user>/.ssh/authorized_keys
Copy Private Key To Give to New User
------------------------------------
nano <new user>
Create Upload Dir && Create Group
-------------
sudo groupadd <new group>
sudo usermod -a -G <new group> <new user>
sudo usermod -a -G <new group> ec2-user
sudo mkdir /home/uploads/<new user>
sudo chgrp -R <new group> /home/uploads/<new user>
sudo chmod -R 770 /home/uploads/<new user>
sudo chown ec2-user:<new group> /home/uploads/<new user>
Delete User
-----------
sudo userdel -r <new user>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment