Skip to content

Instantly share code, notes, and snippets.

@SudhanPlayz
Last active January 1, 2022 08:41
Show Gist options
  • Save SudhanPlayz/0e88f103b0ddb01ee191abce98cbd1e2 to your computer and use it in GitHub Desktop.
Save SudhanPlayz/0e88f103b0ddb01ee191abce98cbd1e2 to your computer and use it in GitHub Desktop.
Topic's in this gist: Connecting to Ubuntu VM, Installing nodejs, Generating SSH key and cloning GitHub repo using git

Deploy GitHub Repo Using SSH Keys

Bought a new VPS? Don't know to use it? this will be help you!

Table of Contents

Connecting to VPS(ssh Method)

Probably you came from my YouTube so I will say you how to connect

Installing Git Bash

  • Download the Git Bash setup from the official website: https://git-scm.com/ Installing Git Bash

  • Download the installer.

  • Run the .exe file you just downloaded and follow the instructions in the installer.

  • Run Git Bash by right-clicking on any folder and selecting the Git Bash Here option from the context menu(right-click menu).

Connecting to VPS

If you came from my YouTube you will have .pem file

Things you need to connect

  • Private Key(.ppk or .pem
  • IP of the VPS
  • Username of the VPS
  • Git Bash

Connecting

Run this command on Git Bash terminal ssh -i "Private Key.pem" Username@ip Follow the above method. When you follow you will get something like ssh -i "Private Key.pem" ubuntu@38.21.32.2

After you run say yes it ask you something

You have successfully connected! If you got a screenshot like this Nice you connected

If you are lazy you type one by one copy this XD

sudo -i && sudo apt update -Y && sudo apt install npm && npm i n -g && n lts && ssh-keygen && cat /home/root/.ssh/id_rsa.pub When you done you will have Node.js! Then add the ssh key to github

Generating ssh key

When you connected do sudo -i so you get root access! Update your ubuntu by sudo apt update -Y

Generate ssh key

Run ssh-keygen then keep press enter untill it stop asking questions Generated Key

So now you will have to copy the ssh key and need to paste on your GitHub(if you dont have github account then create) Run this command to show ssh key cat /home/root/.ssh/id_rsa.pub Now you get something like this Ssh Key Now copy that key!

Adding ssh key to GitHub

Quick link: https://github.com/settings/ssh/new

Go there and add new ssh key Adding ssh key to GitHub

Now you can access your account on GitHub which means you can clone private repo also

Downloading Node.js

Im lazy to type so run this command lol sudo apt install npm && npm i n -g && n lts Now you have Node.js v12

Cloning GitHub Repo

  • On GitHub, navigate to the main page of the repository.
  • Above the list of files, click Code.
  • To clone the repository using an SSH key, including a certificate issued by your organization's SSH certificate authority, click Use SSH, then click . To clone a repository using GitHub CLI, click Use GitHub CLI, then click .
  • Type git clone, and then paste the URL you copied earlier. $ git clone PasteCopiedURLHere
  • Press Enter to create your local clone.
  • Change ExpressApp to the name of the folder you need

$ git clone PasteCopiedURLHere ExpressApp

> Cloning into "ExpressApp"... > remote: Counting objects: 10, done. > remote: Compressing objects: 100% (8/8), done. > remove: Total 10 (delta 1), reused 10 (delta 1) > Unpacking objects: 100% (10/10), done.

  • When it cloned you can see the folder by using ls command
  • Do cd ExpressApp. Change ExpressApp to the folder you cloned

Running & Install packages

Install yarn yarn nice. npm not nice

  • Run npm i yarn -g
  • Do yarn in the folder you cloned
  • Now you have installed all packages! Time to run the code
  • Run screen then press enter now run the code using node index or npm start or anything.
  • After the code executing and running you can do CTRL + A + D to deattach. So terminal runs 24/7 so your app will be 24/7!
  • If you want to return back to that terminal do screen -r!

There you go. Have questions? Comment or Join Discord

@adinetech
Copy link

Wow Nice

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