stephnangue / openlab

0 stars 0 forks source link

9. Configure a SSH reference to a remote repository #16

Open stephnangue opened 1 year ago

stephnangue commented 1 year ago

Show a figure to resume the chapter

Generate a SSH key pair

On Unix : ssh-keygen -b 2048 -t rsa -f $HOME/git_rsa -q -N "" On Windows : ssh-keygen -b 2048 -t rsa -f C:/temp/git_rsa -q -N ""

Show the content of 'git_rsa.pub'

cat $HOME/git_rsa.pub

Store the content of that file on GitHub

Tell Git to use the private key 'git_rsa' to connect to remote repositories via SSH when you are working in the repository 'bootstrap'

cd bootstrap git config --list --local git config --local core.sshCommand "ssh -i $HOME/git_rsa -o StrictHostKeyChecking=no" git config --list --local

Add GitHub.com public key into your 'known_hosts' file

ssh-keyscan -H github.com >> $HOME/.ssh/known_hosts

Create the remote repository 'bootstrap' on GitHub

Add a SSH reference to that remote repository

git remote add github git@github.com:stephnangue/bootstrap.git

Push the content of the main branch to the remote repository, including all tags

git push github main --tags

Notice that there is now a remote main branch pointing to the same commit as the local remote branch

git branch -va git log --graph --oneline