VPS > Prepare users & login
How to manage your UpdateCase VPS
# 1 > ADMIN: Prepare USERS
UpdateCase servers use a user 'staff' to allow mutliple people to access a server efficiently.
- Login to the server using admin access
Create a 'undostaff' user
sudo adduser undostaff
Use the level1 password when asked
Give the user 'sudo' access
sudo usermod -a -G sudo undostaff
# 2 > USER: setup SSH keys
In order to access remote servers you will need to create a SSH key on your computer.
STEP 1: FIRST TIME ONLY: Open a terminal window
ssh-keygen -t rsa
Enter file in which to save the key (/home/USERNAME/.ssh/id_rsa): [push enter to accept the default]
Enter passphrase (empty for no passphrase): [it is suggested you enter a simple phrase only known to yourself
Enter same passphrase again: [enter it again]
You will then get a confirmation that the key has been created
STEP 2: Give the public key to your administrator
Open a TERMINAL window and type
Copy the information into your clipboard
Email this information to your ADMIN so they can install this key into the remote server
# 3 > ADMIN: Install user key to remote server
In order to give users access to each remote server their SSH public key will need to be installed.
-> The user will send their PUBLIC key to you (id_rsa.pub)
Logon to the server using the admin user
Navigate to '.ssh' directory of the 'Staff' user
OPTIONAL: If you do NOT see a .ssh directory you need to create it
Move into the .ssh directory
Edit/Create the file 'authorized_keys'
sudo vi authorized_keys
Create a new line in the file (at the bottom) and add the following
ssh-rsa AAAAB3N...................ZMBjl sacha-lewis@ubuntu
Change the permissions to lock down the file (first time only)
sudo chown undostaff:undostaff authorized_keys
sudo chmod 600 authorized_keys
The new user is now able to login using SSH keys
# 4 > USER: Logon to server
Now that your SSH public key has been added to the remote server
-> You are now able to logon to the server using the staff user
Open a TERMINAL window
If you get prompted for your passphrase, enter what you created
NOTE: if you get the error: sign_and_send_pubkey: signing failed: agent refused operation
Enter passphrase for /home/sacha-lewis/.ssh/id_rsa: [Enter your passphrase]
Identity added: /home/USERNAME/.ssh/id_rsa (/home/USERNAME/.ssh/id_rsa)
You are now logged in
# 5 > Location of website files
There are a few different locations website files can be
1. Basic website servers
cd www/test [this is the test.domain.com location]
cd www/test/dev [this is the test.domain.com/dev location]
cd www/test/client [this is the test.domain.com/client location]
cd www/www [this is the live website www.domain.com]
2. Software as a service servers
#this will display all the websites which are installed on this server
#change into the website directory
#there is a directory www which has the actual website
# 6 > OPTIONAL: Delete and clean up if issues
There are times when updating the code does not work, so you might need to delete all the files and re-export
-> Always test on CLIENT / DEV BEFORE you do any work on a LIVE website.
Navigate to the directory where you want to delete
-> ENSURE YOU do NOT do this in a different directory as you could disrupt the server functions.
-> EG to change CLIENT location
rm -rf *
rm -rf .*
This now removes ALL files from the TEST CLIENT website, and you can now re-export all the files and all should be well again
# 7 > Export files
To export files there might be scripts to automate the process
->eg /var/www/vhosts/site.com might have: www_1setup.sh / www_2ForceLive.sh / www_3goLIVE.sh
-> Simple run these files to update the servers files "./www_1setup.sh"
IF there are NO automated scripts you can launch the changes manually.
-> Here is the quick and dirty way to delete the LIVE folder (you will experience downtime after you run that command), and then export the code to this directory
svn export --force LOCATIONOFCODE . --username USER
-> GITHUB it will be: https://github.com/USERNAME/PROJECT/trunk/back-end/.
-> SVN it will be: https://svn.undologic.com/updateCase/PROJECT/trunk/.
After you proceed you will be prompted for your password
-> and you can 'save' the password on the server