DEV Community

EJEH
EJEH

Posted on • Edited on

Easy way to clone public/private repo on android device via SSH

In an era where smartphones continue to advance in sophistication, there may come a time when you find yourself without access to your computer system and wish to utilize your Android phone to clone a private repository from GitHub. This can be particularly useful if you need to make alterations or edit lines of code and subsequently push those changes back to your Git repository. today in this tutorial I will show you how to make that possible. below are the Prerequisites.

Prerequisite
Android phone
Github or any other version control account
Termux

Install Termux and open it. then run this command to install git on your android phone via termux.

pkg install git
Enter fullscreen mode Exit fullscreen mode

**NOTE:

First commit after installing git you have to specify who you are git config --global user.name "" git config --global user.email ""

To clone a private repository via Git, you typically add your android **SSH public key to your GitHub account. This allows you to authenticate and access private repositories securely without needing to enter your username and password each time. Your private key should be kept secure on your local machine, while the public key is shared with GitHub to verify your identity when you make Git operations like cloning, pushing, or pulling from private repositories.

ssh-keygen -t rsa -b 4096 -C "your-github@mail.com"
Enter fullscreen mode Exit fullscreen mode

OR

ssh-keygen -t ed25519 -C "your-github@mail.com"
Enter fullscreen mode Exit fullscreen mode

ssh-keygen timux

The command ssh-keygen -t rsa is used to generate an SSH (Secure Shell) key pair with RSA encryption.

termux ssh

copy the public key

termux

check out the official github on how to add your own ssh

Adding a new SSH key to your account

In the "Access" section of the sidebar, click SSH and GPG keys.

Click New SSH key or Add SSH key.

In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal laptop, you might call this key "Personal laptop".

timux and github

you can also test if your connection is successful using this command

ssh -T git@github.com
Enter fullscreen mode Exit fullscreen mode

"After completing the above process, you can now return to your Android terminal and test by cloning a private repository.

This tutorial will serve as a foundation for upcoming tutorials on how to utilize your Android smartphone as a helpful tool."

Follow me on X for more.. Ejeh on X

Top comments (0)