Category Archives: ssh

Getting started with github

Github is a source code repository hosting service. It uses git as the version control system and it is free for open source projects.

You need to register, thereafter you can create or fork a repository, follow the instructions in the help section.

Creating SSH keys
You can skip this step if you want to because you can cache your github password for a period of time (see set up git, scroll down to password caching).

However to be more secure and instead of having to specify your login credentials each time you want to commit to a repository or after password caching has expired, it is really helpful using SSH keys. Here is how you would do this with Linux:

  1. In your shell, create a .ssh directory mkdir -p ~/.ssh, then change to it cd ~/.ssh.
  2. ssh-keygen -t rsa -C “your-email-address-here” (this will ask your for a filename and password).
  3. You should have 2 files with the same name but one has a “.pub” extension (these are your private and public keys respectively).
  4. Copy the contents of your .pub key to your clipboard less ~/.ssh/your-key-file.pub and copy all the contents of the file. Or if you’re paranoid about missing anything out then use xclip -sel clip < ~/.ssh/your-key-file.pub (you will need to install xclip).
  5. Login to github, choose “account settings”, scroll down to “SSH Keys”, then give a name for your key and CTRL+V to copy the contents of your clipboard into the key field.
  6. Test with ssh -T [email protected] (leave [email protected] as is), type in the password used in step 2 and you should receive a message along the lines of “Hi binarycodifier! You’ve successfully authenticated”.

Creating a repository
This can be achieved on the server side, login to github and simply follow the create repository instructions. The server side repository creation is really easy. However if you want to create a repository from your machine, you will need to use the github API, see the repo create option.

Clone your repository locally
In order to work on repository code, you will need to have a copy of the code locally on your computer from the repository you created – this is called cloning.

  1. Go to one of your repositories on github.
  2. At the top, choose the “Code” tab, you should then see “Zip, HTTP, SSH and Git Read-Only” options.
  3. For normal password authentication choose “HTTP”, for SSH key based authentication choose “SSH”. Copy the URL next to the option you chose.
  4. Create or change to a directory on your local computer.
  5. On your local computer use git clone github-repository-url you copied in step 3.
  6. You should be able to see a new directory matching your github repository on your computer.

Updating repository
On your local computer you will be making the changes. Thereafter you will push these changes back to the github server. Follow these steps:

  1. Change directory to the copy of your repository directory on your local computer.
  2. Update file(s), save and then add git add . (note the dot).
  3. Commit the files with a message of the change git commit -a -m “updated X”.
  4. Push the changes to the github server git push.
  5. Browse your github repository and check to see that the changes did indeed get pushed.

References:

  1. Github – Wikipedia reference.
  2. SSH Keys – Wikipedia reference about SSH communication.
  3. Github generating SSH key – creation and testing SSH key with github.
  4. Git manual – on line manual for git.