Working with private Github repositories

In this article, you will be presented with instructions for working with private repositories on shared hosting.

Why with private repositories? It’s simple because when working with open (public) repositories, you do not need to take additional security steps, such as: generating SSH keys, SSH authorization in GitHub, generating a security token, etc.

Below is the instruction for you:

      1. Connect via ssh
      2. Run the command:
        ssh-keygen -t rsa -f ~/.ssh/sshkeygit -b 4096 -C ""

        • sshkeygit – is the name of your key that is being generated. You can enter any name
        • username – is your username on


        • Next, you are asked to enter a password for the key:
          Generating public/private rsa key pair.
          Enter passphrase (empty for no passphrase):
        • Next, you are asked to repeat the password for the key:
          Enter same passphrase again:
        • If everything is successful, you will see the following output:
          Your identification has been saved in /home/username/.ssh/sshkeygit.
          Your public key has been saved in /home/username/.ssh/
          The key fingerprint is:
          The key's randomart image is:
          +---[RSA 4096]----+
          |                      o.+ oo+|
          |                     . = B.*.|
          |                     .oo=.O. |
          |                    o.o +B.o |
          |                    Sooo.oo .|
          |                    . +o. .. |
          |                      .oo .o |
          |                    o.+. . .+|
          |                     oE*o .o=|
        • Run the command:
          cat .ssh/
        • And we get something like this:
        • Copying the content
      3. Go to the site – log in to the site – go to Setting – then to the SSH and GPG keys section – in the SSH keys block, click on the New SSH key button – paste the content from step 2
      4. We return to the terminal and check the connection by running the command:
        ssh -i .ssh/sshkeygit -T

        • We see the following message:
          The authenticity of host ' (' can't be established.
          ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
          ECDSA key fingerprint is MD5:7b:99:81:1e:4c:91:a5:0d:5a:2e:2e:80:13:3f:24:ca.
          Are you sure you want to continue connecting (yes/no)?
        • We write “yes”, press Enter, and see the following message:
          Enter passphrase for key '.ssh/sshkeygit':
        • We write the password that was indicated in the first step. If everything is done correctly, you will see the following response:
          Hi username! You've successfully authenticated, but GitHub does not provide shell access.
        • This means that you are doing good and almost ready to work with GitHub. Why “almost”? Let’s figure it out in the next step.
      5. If you try to clone the repository by issuing the command:
        git clone

        • You will receive the following message:
          Клонирование в «blog»…
        • Next, you will be asked to enter a login and password from the Github site:
          Username for '':
          Password for '':
        • And instead of cloning the repository, you will see the following warning and error:
          remote: Support for password authentication was removed on August 13, 2021.
          remote: Please see for information on currently recommended modes of authentication.
          fatal: Authentication failed for ''
      6. In order to clone the repository, go to the website in your account settings – then go to the Developer settings section – then to Personal access tokens and click on the Generate new token button. To create a token, fill in the following fields:
        • filling in the Note field
        • selection of the lifetime of the token Expiration
        • selection of the scope of the token Select scopes, for this instruction, the “repo” section will suffice
        • To create a token, click on the Generate token button

        In the “Personal access tokens” section, the created token will be visible: ghp_jo0VFGSoG002PxLXO7uDEg8juFW3JT48iZ9Q (this is not a working example)

        Copy it and go to the terminal.

      7. Now you can execute the clone command, but it will look like this:
        git clone https://<username>:<githubtoken><username>/<repositoryname>.git

        • and now, following the example, run the command:
          git clone

          • note that https://<username> — username – must be git


        • and if you did everything correctly, you will get the following response:
          Клонирование в «blog»…
          remote: Enumerating objects: 3, done.
          remote: Counting objects: 100% (3/3), done.
          remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
          Получение объектов: 100% (3/3), готово.
Rate this article
Share this article
Notify of
Inline Feedbacks
View all comments
In this article