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
- Show one of the easiest ways to clone private GitHub repository.
- Train your console skills.
Prepare setup
First, connect to your server (Droplet, VDS, etc) and generate SSH key:
$ sudo ssh-keygen
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
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
Add copied public key to Deploy Keys section:
Don’t forget to check Allow write access.
That’s it. 🎉
Let’s clone it!
You may git clone
your private repository to server by command:
$ sudo git clone project_name:<user>/<repo>.git
How to update?
For update, type into your project directory:
$ git pull
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! 👇
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
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
Run ./init.sh
from root dir:
foo@bar:~$ cd vsac
foo@bar:~$ sudo chmod +x ./init.sh
foo@bar:~$ sudo ./init.sh [OPTIONS]
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
…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 happen when your run
cat ./file.txt
command at console? - Why a
sudo
command prefix are important?
If you want more articles (like this) on this blog, then post a comment below and subscribe to me. Thanks! 😻
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 projects that need your help (and stars) 👇
- 🔥 gowebly: A next-generation CLI tool for easily build amazing web applications with Go on the backend, using htmx & hyperscript and the most popular atomic/utility-first 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.
- 🏃 yatr: Yet Another Task Runner allows you to organize and automate your routine operations that you normally do in Makefile (or else) for each project.
- 📚 gosl: The Go Snippet Library provides snippets collection for working with routine operations in your Go programs with a super user-friendly API and the most efficient performance.
- 🏄♂️ csv2api: The parser reads the CSV file with the raw data, filters the records, identifies fields to be changed, and sends a request to update the data to the specified endpoint of your REST API.
- 🚴 json2csv: The parser can read given folder with JSON files, filtering and qualifying input data with intent & stop words dictionaries and save results to CSV files by given chunk size.
Top comments (4)
Awesome! One minor issue is that the host should also be
github.com
In your ~/ssh/config the first line
Host github.com
Actually, nope :) but thx to reply.
Host
variable is a simple alias for calling this block inssh <host>
orgit clone <host>:...
and else. You can set any valid word for it, like usual alias for console commands in bash config.I know right. But it only worked once I did that. Maybe server was configured that way or something?
@koddr will 'Deploy keys' work on private repo in a free GitHub account ?
When I try I get the error:
Cloning into 'test'...
Warning: Permanently added the ECDSA host key for IP address '192.30.255.113' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.