Created
September 10, 2012 21:47
-
-
Save FernandoEscher/3694140 to your computer and use it in GitHub Desktop.
Server configuration for Rails: Creation of admin user.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some steps were taken from: http://blog.sofasurfer.org/2011/07/16/ubuntu-ec2-add-new-admin-user/ | |
# Create new user and follow the steps | |
sudo adduser MyAppName | |
# Add the user to the admin group to have sudo access | |
sudo adduser MyAppName admin | |
# If you want to allow sudo access without password (Insecure) | |
sudo visudo | |
#Add this line to the file | |
MyAppName ALL=(ALL) NOPASSWD:ALL | |
#Now you can follow one of the following options to have access to your server: | |
##Option A## | |
# Exit your server | |
exit | |
# Copy your rsa public key in your computer | |
cat .ssh/id_rsa.pub | |
# Access your server and append the key to your authorized keys | |
vim .ssh/authorized_keys | |
---- OPTION DONE --- | |
##Option B## | |
# Generate your rsa key | |
ssh-keygen -t rsa | |
# Rename your keys | |
mv .ssh/id_rsa .ssh/id_MyAppName_rsa | |
mv .ssh/id_rsa.pub .ssh/id_MyAppName_rsa.pub | |
# Add the public key to the authorized keys | |
cat .ssh/id*.pub > .ssh/authorized_keys | |
# Copy keys to tmp folder to download | |
cp .ssh/id* /tmp | |
chmod 644 /tmp/id* | |
# Exit the server | |
exit | |
# Copy the public key from the server to your .ssh folder | |
scp [email protected]:/tmp/id_MyAppName_rsa .ssh/ | |
# Change the permissions of your key | |
chmod 400 .ssh/id_MyAppName_rsa | |
#Login the server and remove the keys from the tmp folder | |
rm -rf /tmp/id* | |
---- OPTION DONE --- | |
# Change the permissions to the .ssh folder | |
chmod 700 .ssh | |
# Change the permissions of the files inside .ssh | |
chmod 600 .ssh/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment