Skip to content

Instantly share code, notes, and snippets.

@raulqf
Last active March 11, 2019 00:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raulqf/e56ddf91599b954e2850afc64e99fe0b to your computer and use it in GitHub Desktop.
Save raulqf/e56ddf91599b954e2850afc64e99fe0b to your computer and use it in GitHub Desktop.
This gist explains how to set an environment to deploy easily your project in your production server.

Configure a working environment to easily Deploy your project using Git

This gist explains how to set a working environment to deploy easily your project in your production server. To this aim a git bare repository is set in the remote server which is used for control versions as well as to upload and deploy your progress to the production server.

The structure of the proposed environment consists of 3 parts:

  1. Working directory (Local)
  2. Deployment directory (Remote Server)
  3. Git bare repository (Remote Server)

So the idea is to set your working directory and the deployment directory under control version using the git bare repository. In such a way that the upload channel is established by means of push operations to the remote server whereas the updates in the deployment directory are carried out using pull requests. Below are detailed the different steps to configure such environment.

Configure SSH

As it's known the SSH mechanism employs two keys to assure secure connections. One key is the public to be shared with end-points for establishing connections, whereas the private key must be securely stored. (How does ssh work?)

Let's walk through the SSH configuration in a server running on a standard linux distribution as Ubuntu, for instance. First, the authorized_keys to store the public keys from remote users must be created with the following commands:

$ mkdir ~/.ssh/
$ touch ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys

Now, the public key from those git users to be authorized must be appended to the authorized_keys. The public key is stored within the .ssh folder named as id_rsa_pub. If that file does not exist in the git user, a signature for that user must be previously created. It can be easily done using ssh-keygen utility packaged with ssh.

$ ssh-keygen -c yourmail@mailprovider.com 

To avoid errors copying the public key it is recommended to upload the file containting the public key id_rsa.pub and dump its content into authorized_keys. With scp you can upload the git user public key into the server and append its content using cat redirecting its output to authorized_keys file .

//Git user client machine
$ scp user@pi id_rsa.pub

//Git server
$ cat id_rsa.pub >> ~/.ssh/authorized_keys

To check if it has been performed correctly, try to connect to the remote server where no password will be required.

$ssh user@ip 

If password is requried, check folder permissions.

$chmod 700 ~/.ssh
$chmod 600 ~/.ssh/authorized_keys
$chmod go-w ~

Configure Git server using Bare mode

Check if the nouveua has been disabled correctly:

$ lsmod | grep nouveau //It should output a negative value

Remove all the NVIDIA packages:

$ sudo apt-get purge nvidia* 

Reboot the machine and stop the display manager or your SO (gmd3, sddm, kdm, lightdm are different display managers) by accessing to the TeleTYpewriter (TTY) using Ctrl+Alt+F1:

sudo service lightdm stop  
sudo /etc/init.d/gdm stop

Install the drivers using a repository or downloading the package:

Using a repository
$ sudo apt-get purge nvidia* 
$ sudo add-apt-repository ppa:graphics-drivers
$ sudo apt-get update 
$ sudo apt-get install nvidia-3xx //Reboot your computer after installing

You can also download the driver from the NVIDIA website in .deb format and run the following commands:
$ sudo dpkg -i nvidia-diag-driver-local-repo-ubuntu1604-390.46_1.0-1_amd64.deb
$ sudo apt-get update
$ sudo apt-get -y install cuda-drivers

Test the installation:

  $ lsmod | grep nvidia  //Check status. It should not be empty
  • If you have problems with nouveau try to update the initramfs and repeat the proces *

      sudo update-initramfs -u
    

TL;DR:

TTY in Ubuntu 17.10 goes from Ctrl+Alt+F3 up to Ctrl+Alt+F7 and Ctrl+Alt+F2 to go back to the desktop environment.    

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment