First, configure your Git with your GitHub account details.
git config --global user.name "pythonkid2"
git config --global user.email "mjcmathew@gmail.com"
-
Generate a new SSH key:
ssh-keygen -t ed25519 -C "mjcmathew@gmail.com"If you are using a legacy system that doesn't support the Ed25519 algorithm, use:
ssh-keygen -t rsa -b 4096 -C "mjcmathew@gmail.com" -
When prompted to "Enter a file in which to save the key," press Enter to accept the default file location.
-
At the prompt, type a secure passphrase (optional but recommended).
-
Start the SSH agent:
eval "$(ssh-agent -s)" -
Add your SSH private key to the SSH agent:
ssh-add ~/.ssh/id_ed25519If you used a different name for your key, replace
id_ed25519with your key's name.
-
Copy the SSH key to your clipboard:
cat ~/.ssh/id_ed25519.pubIf you used a different name for your key, replace
id_ed25519.pubwith your key's name. -
Log in to your GitHub account.
-
In the upper-right corner, click your profile photo, then click Settings.
-
In the user settings sidebar, click SSH and GPG keys.
-
Click New SSH key.
-
In the "Title" field, add a descriptive label for the new key (e.g., "Personal Laptop").
-
Paste your key into the "Key" field.
-
Click Add SSH key.
-
If prompted, confirm your GitHub password.
Navigate to your project directory and initialize a Git repository.
cd /new
git init
Add the files you created to the Git repository.
git add .
Commit the files with a message.
git commit -m "Initial commit with 1 to 7.txt files"
- Go to GitHub and log in to your account.
- Click on the "New" button to create a new repository.
- Name your repository (e.g., "new-repo").
- Add a description if you like.
- Choose the visibility (public or private).
- Do not initialize the repository with a README, .gitignore, or license.
- Click "Create repository."
Copy the SSH URL of your new repository from GitHub and add it as a remote in your local Git repository.
git remote add origin git@github.com:pythonkid2/new-repo.git
Push your local repository to GitHub.
git push -u origin master
Following these steps will set you up with SSH and allow you to push your files to GitHub securely.