How to clone your private repository from GitHub to server, Droplet, VDS, etc?

Vic Shóstak - Jan 6 '20 - - Dev Community

Introduction

Welcome back! The “(Quick) How to” series continue.

Today, we solve huge misunderstood thing: clone private repository from GitHub on your server. Don’t switch the channel 😃

Objectives of the article

  1. Show one of the easiest ways to clone private GitHub repository.
  2. Train your console skills.

Prepare setup

First, connect to your server (Droplet, VDS, etc) and generate SSH key:

$ sudo ssh-keygen
Enter fullscreen mode Exit fullscreen mode

If you want, choose path and name for your key. I always use default path (~/.ssh) and name, like project_name_rsa.

Next step, create SSH config:

$ sudo cat >~/.ssh/config <<EOL

Host project_name
Hostname github.com
User git
IdentityFile ~/.ssh/project_name_rsa

EOL
Enter fullscreen mode Exit fullscreen mode

Don't forget to change my project_name to yours!

OK! Copy public key to clipboard and go to your GitHub repository settings:

$ sudo cat ~/.ssh/project_name_rsa_key.pub
Enter fullscreen mode Exit fullscreen mode

Add copied public key to Deploy Keys section:

github allow write access

Don’t forget to check Allow write access.

That’s it. 🎉

let's clone private git repo

Let’s clone it!

You may git clone your private repository to server by command:

$ sudo git clone project_name:<user>/<repo>.git
Enter fullscreen mode Exit fullscreen mode

How to update?

For update, type into your project directory:

$ git pull
Enter fullscreen mode Exit fullscreen mode

What’s next?

Get automation of routine tasks on a new server (Droplet, VDS, etc) with Virtual Server Auto Config (or VSAC for short). Just git clone and run it! 👇

GitHub logo koddr / vsac

✅ Аutomation of routine tasks on a new server for humans. Only verified configs and best practices. Just git clone and run it!

✅ Virtual Server Auto Config

version linux license

The Why?

Аutomation of routine tasks on a new server for humans. Only verified configs and best practices.

Just git clone and run it!

For GNU/Linux Debian 9 Stretch

Clone this repo:

foo@bar:~$ git clone https://github.com/koddr/vsac.git
Enter fullscreen mode Exit fullscreen mode

Run ./init.sh from root dir:

foo@bar:~$ cd vsac
foo@bar:~$ sudo chmod +x ./init.sh
foo@bar:~$ sudo ./init.sh [OPTIONS]
Enter fullscreen mode Exit fullscreen mode

Options

  • --webserver [NAME] — web server name, you want to install (support: nginx);
  • --python [VERSION] — Python 3 version, you want to install (support: 3.5.x, 3.6.x, 3.7.x, 3.8.x)
  • --postgresql [DATABASE] — PostgreSQL with database name, you want to install

Nginx configuration

user nginx
+ worker_processes auto;

events {
+   use epoll;
    worker_connections 1024;
+   multi_accept on;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log off;
    error_log /var/log/nginx/error.log crit;
+   server_tokens off;

+   keepalive_timeout 30;
+   keepalive_requests 100;

+   reset_timedout_connection on;
+   client_body_timeout
Enter fullscreen mode Exit fullscreen mode

Photos by

[Title] Nicole Wolf https://unsplash.com/photos/CZ9AjMGKIFI
[1] Azharul Islam https://unsplash.com/photos/9LMGWHqUwnc

P.S.

Questions for self-study practice:

  • Which console command may generate SSH key?
  • What’s to happen when you run cat ./file.txt command at console?
  • Why a sudo command prefix is important?

If you want more articles (like this) on this blog, then post a comment below and subscribe to me. Thanks! 😻

❗️ You can support me on Boosty, both on a permanent and on a one-time basis. All proceeds from this way will go to support my OSS projects and will energize me to create new products and articles for the community.

support me on Boosty

And of course, you can help me make developers' lives even better! Just connect to one of my projects as a contributor. It's easy!

My main projects that need your help (and stars) 👇

  • 🔥 gowebly: A next-generation CLI tool that makes it easy to create amazing web applications with Go on the backend, using htmx, hyperscript or Alpine.js and the most popular CSS frameworks on the frontend.
  • create-go-app: Create a new production-ready project with Go backend, frontend and deploy automation by running one CLI command.

Other my small projects: yatr, gosl, json2csv, csv2api.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player