[TOC]

Create your SSH keys with the ssh-keygen command from the bash prompt. This command will create a 2048-bit RSA key for use with SSH. This command will create a 2048-bit RSA key for use with SSH. You can give a passphrase for your private key when prompted—this passphrase provides another layer of security for your private key. Generate a new SSH key pair. GitHub Gist: instantly share code, notes, and snippets. Mac and Linux. Generate a 4096-bit key pair - yes, use the higher bit. Jul 14, 2019  To generate a new SSH key pair, run the following command (replace youremail@example.com with your email address). GitLab and Bitbucket allow you to test whether SSH connection has been set up correctly before actually using it with Git. After you’ve added your SSH key to your GitHub account, open the terminal and run. We are able to generate SSH keys, upload the public part, and then we can interact with GitHub. We are able to accomplish same in Gitlab servers or BitBucket. Here is a part I don't understand. In the newer Mac OS, the user accounts don't have ssh-agent launched within each session and the user key is not remembered. As far as I can tell, when a user wants to interact with GitHub or some other Git remote. Sep 27, 2018 Above will generate two key files, idrsagithub will be private key and idrsagithub.pub will be public key. Once ssh keys are generated as above, head towards configuring keys. If you are running github client on the unix like operating system then you can generate ssh keys inside your home directory. If you don't have an existing public and private key pair, or don't wish to use any that are available to connect to GitHub, then generate a new SSH key. If you see an existing public and private key pair listed (for example idrsa.pub and idrsa) that you would like to use to connect to GitHub, you can add your SSH key to the ssh-agent.

Mac

Overview

OSG Connect requires SSH-key-based logins. You need to followa two-step process to set up the SSH key to your account.

  1. Generate a SSH key pair.

  2. Add your public key to the submit host by uploading it toyour OSG Connect user profile (via the OSG Connect website).

After completing the process, you can log in from a local computer(your laptop or desktop) to the OSG Connect login node assignedusing either ssh or an ssh program like Putty -- see below formore details on logging in.

NOTE: Please do not edit the authorized keys file on the login node.

Step 1: Generate SSH Keys

We will discuss how to generate a SSH key pair for two cases:

  • 'Unix' systems (Linux, Mac) and certain, latest versions of Windows
  • Older Windows systems

Please note: The key pair consist of a private key and a public key. You will upload thepublic key to OSG Connect, but you also need to keep a copy of the private key to log in!
You should keep the private key on machines that you havedirect access to, i.e. your local computer (your laptop or desktop).

Unix-based operating system (Linux/Mac) or latest Windows 10 versions

Open a terminal on your local computer and run the following commands:

The last command will produce a prompt similar to

Unless you want to change the location of the key, continue by pressing enter.Now you will be asked for a passphrase. Enter a passphrase that you will beable to remember and which is secure:

When everything has successfully completed, the output should resemble thefollowing:

The part you want to upload is the content of the .pub file (~/.ssh/id_rsa.pub)

Windows, using Putty to log in

If you can connect using the ssh command within the Command Prompt (Windows 10 build version 1803 and later), please follow the Mac/Linux directions above. If not,continue with the directions below.

  1. Open the PuTTYgen program. You can download PuttyGenhere: PuttyGen Download Page,scroll down until you see the puttygen.exe file.

  2. For Type of key to generate, select RSA or SSH-2 RSA.

  3. Click the 'Generate' button.

  4. Move your mouse in the area below the progress bar.When the progress bar is full, PuTTYgen generates your key pair.

  5. Type a passphrase in the 'Key passphrase' field. Type the same passphrase in the 'Confirm passphrase' field. Youcan use a key without a passphrase, but this is not recommended.

  6. Click the 'Save private key' button to save the private key. You must save the private key. You will need it to connect to your machine.

  7. Right-click in the text field labeled 'Public key for pasting into OpenSSH authorized_keys file' and choose Select All.

  8. Right-click again in the same text field and choose Copy.

Step 2: Add the public SSH key to login node

To add your public key to the OSG Connect log in node:

  1. Go to www.osgconnect.net and sign in with the institutional identity you used when requesting an OSG Connect account.

  2. Click 'Profile' in the top right corner.

  3. Click the 'Edit Profile' button located after the user information in the left hand box.

  4. Copy/paste the public key which is found in the .pub file into the 'SSH Public Key' text box.The expected key is a single line, with three fields looking something likessh-rsa ASSFFSAF... user@host. If you used the first set of key-generatinginstructions it is the content of ~/.ssh/id_rsa.pub and for the second (usingPuTTYgen), it is the content from step 7 above.

  5. Click 'Update Profile'

The key is now added to your profile in the OSG Connect website. This will automaticallybe added to the login nodes within a couple hours.

Logging In

After following the steps above to upload your key and it's been a few hours, you shouldbe able to log in to OSG Connect.

Determine which login node to use

Before you can connect, you will need to know which login node your account is assigned to. You can findthis information on your profile from the OSG Connect website.

  1. Go to www.osgconnect.net and sign in with your CILogin.

  2. Click 'Profile' in the top right corner.

  3. The assigned login nodes are listed in the left side box. Make note of the address ofyour assigned login node as you will use this to connect to OSG Connect.

For Mac, Linux, or newer versions of Windows

Open a terminal and type in:

It will ask for the passphrase for your ssh key (if you set one) and then youshould be logged in.

For older versions of Windows

On older versions of Windows, you can use the Putty program to log in.

  1. Open the PutTTY program. If necessary, you can download PuTTY from the website here PuTTY download page.

  2. Type the address of your assigned login node as the hostname (see 'Determine which login node to use' above).

  3. In the left hand menu, click the '+' next to 'SSH' to expand the menu.

  4. Click 'Auth' in the 'SSH' menu.

  5. Click 'Browse' and specify the private key file you saved in step 5 above.

  6. Click 'Open' and provide your passphrase when prompted to do so.

Getting Help

For assistance or questions, please email the OSG User Support team at mailto:support@opensciencegrid.org or visit the help desk and community forums.

There is an updated version of this post for OS X 10.9. While the steps below should still work, I recommend checking out the new guide if you are running 10.9!

There are already plenty of guides that explain the particular steps of getting Git and Github going on your mac in detail. However, I had difficulty finding one that explained every step required in order with simple enough instructions for Terminal novices to follow along with autonomously.

So I decided to write one myself.

Background

I enjoy helping people become more efficient and productive, particularly when it comes to their computers and mobile devices. At a recent job, the staff design team was beginning a period of close collaboration with the front-end development team in the interest of achieving the best possible product in the shortest period of time.

However, there was a slight “problem.” The project’s codebase was exclusively managed via Git repositories on Github. Most of the designers had never worked with Git, let alone ever configured it on their workstations.

Most of the designers had some knowledge of the technologies that went into the codebase, particularly presentation layer tech like HTML and CSS. Some even knew programming languages like Javascript, PHP, and Ruby.

In an effort to unleash this previously untapped resource for a round of intense polishing and bug-fixing, I took it upon myself to write a step-by-step guide that any member of our studio could follow and be up and running with developer tools, Git, connected to Github, and ready to work on the project codebase.

This then is a slightly abbreviated1 version of the guide I distributed out to the team. Ultimately just a few days after releasing it, nearly everyone in the office — including design, production, management, and even a few devs setting up new machines — was able to at least view the latest code on their workstations.

Aside from the fact that my guide helped others quickly get through the arduous process of installation and configuration, I was happy to have it as a quick reference for myself when setting up new machines of my own. Enjoy!

Getting started

This tutorial assumes you’re using a Mac running at least OS X 10.7. If you are unsure of what OS you have, go up to the top left of your screen, click the Apple menu, and select “About This Mac.”

You’ll also need to ensure that your user account on your computer has admin privileges and that you know your account’s password.

Install the Command Line Tools for OS X

Xcode is a nearly 4GB developer suite Apple offers for free from the Mac App Store. However, for the purposes of getting Git and Github setup, you’ll only need a specific set of command line tools2 which fortunately take up much less space.

If you don’t mind the 4GB, by all means go for Xcode. Otherwise, you’ll have to go to connect.apple.com and register an Apple Developer account in order to download these tools.

Key

Once you’ve registered, they can be found at developer.apple.com/xcode by clicking on “View downloads” and finding the appropriate command line tools for your version of OS X in the list.

  1. If you are on OS X 10.7.x, download The 10.7 Command Line Tools. If you are on OS X 10.8.x, download The 10.8 Command Line Tools.
  2. When your download finishes, go ahead and open the DMG.
  3. Run the Command Line Tools installer.

A note about the Terminal

The Terminal application comes pre-installed with OS X, and can be found in the Applications -> Utilities folder. You can also quickly access it using Spotlight.

The terminal has a variety of uses, but for the purposes of this tutorial we’ll be using a syntax/command set called Bash. Terminal is already configured to use this syntax.

When you enter a command and press return/enter, often times the terminal will execute it and complete the task immediately.

Sometimes it will log information in the window while it’s working, but other times you might feel like it isn’t doing anything at all.

Some of the commands later in this tutorial can take a few seconds (or minutes) to complete, so don’t type anything into the terminal window or close the terminal window until you see it present you with a fresh prompt ending in yourusername$.

For the purposes of this tutorial, commands that I intend for you to type will be preceded with $, but don’t include that symbol when you enter the commands. It’s purely meant as an indicator and reference to the $ that appears in your terminal prompt.

Lines that contain comments/notes from me to will be preceded with # and will be dimmed. Don’t type these either.

Make sure to press return after typing a command before you enter the next one.

Installing Git

“Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.”

We need to install Git onto your computer. It won’t have an icon in your dock, but it can be used by the Terminal (and other applications, more on that later).

OS X comes with a fairly old version of Git pre-installed, so we’ll want to make sure that your terminal is using a more updated version.

One specific reason you’ll want to have a newer version of Git than the one that ships with OS X is to take advantage of a nice authentication feature that allows you to seamlessly interact with Github.

  1. Download the latest stable release of Git. It should start downloading a DMG which for some reason will include the words “Snow Leopard” in the file name…don’t worry, it works with Lion and Mountain Lion just fine.

  2. When it’s done downloading, open the DMG and run the package installer.

    Note: If you are using OS X 10.8 and haven’t already modified your security settings to allow the installation of third-party applications, you’ll need to make that adjustment3 before OS X lets you install these tools.

  3. Once the installer has finished, open the Terminal app and type git --version followed by the return key. Note that there are two dashes, not one.

  4. The terminal should report back with your currently installed Git version.

    If it reports a Git version that matches the version number marked on the DMG you downloaded (as of writing, this would be 1.8.1.3) proceed to Configuring Git identification, otherwise you’ll need to execute the following:

Configuring Git identification

Now let’s configure your Git installation so other folks who might be working on projects with you know who’s doing all of the great work coming from your computer.

Setup Github

GitHub is a web-based hosting service for software development projects that use the Git revision control system.

Go to Github.com and create a free account if you haven’t already.

Mac Generate Ssh Key Github

Github Keychain Helper

To save time in the future, we’ll install a utility that will allow your computer to authenticate with Github automatically instead of having to enter your username/password during each session.

First, check if the helper is installed by typing git credential-osxkeychain into the terminal.

If the helper is installed, the terminal will give you instructions on how to use it:

If see the above message, you are now able to access Git repositories using the HTTPS method. There’s a very good chance that this is the only method you will need to access repositories and you can move on to my final notes.

If you don’t have the keychain helper already installed, you’ll see this instead:

To install the keychain helper, execute the following commands:

Once again, if the helper has been installed successfully, the terminal will give you instructions on how to use it:

If see the above message, you are now able to access Git repositories using the HTTPS method. There’s a very good chance that this is the only method you will need to access repositories and you can move on to my final notes.

If you don’t see the above message, you hit a snag along the way. Try going through the keychain helper install steps again.

Otherwise, if you have a specific reason that you need to access Git repositories using SSH, proceed to SSH Keys.

SSH Keys (optional step)

“SSH uses public-key cryptography to authenticate the remote computer and allow it to authenticate the user, if necessary. There are several ways to use SSH; one is to use automatically generated public-private key pairs to simply encrypt a network connection, and then use password authentication to log on.”

An SSH key basically lets your computer uniquely identify itself when it connects to servers. If Github is aware of the key your computer is using, you won’t have to enter your Github username/password every time you connect.

Check for pre-existing SSH keys on your computer

Let’s see if your computer has one or more keys already installed:

If you get the response “No such file or directory”, skip to Generate a new SSH Key.

Otherwise, you’ll need to backup and remove your existing SSH keys.

Backup and remove your existing SSH keys.
Generate a new SSH key

Now we’ll create a new SSH key to use with Github.

When it asks you to enter a file name in which to save the key, just press return/enter (leave the prompt blank).

You will then be asked to enter a passphrase and confirm it. Don’t make this blank, and don’t make it an easily guessable. This prevents someone from easily acquiring and using your SSH key to impersonate you. Don’t worry, you won’t have to enter this key much (if at all) after initial setup.

Press return after each time you’ve entered your selected passphrase. You won’t see the characters or bullets, the cursor will stay in the same spot as if you aren’t typing.

If you make an error entering your password one of the times, just press return and it will prompt you to try again.

Once you’ve successfully set your passphrase, the terminal will report that your key has been saved and will present you with some sweet ASCII art.

Create Github Ssh Key

Add your SSH key to Github

In order for your computer to access Github without you having to enter your username/password all the time, Github needs to know the contents of the SSH key you just generated.

Github Ssh Key Generate Mac Address

Now we’ll add your key to Github:

  1. Visit your account settings.
  2. Click Add SSH key.
  3. Enter a descriptive title for the computer you’re currently on, e.g. “Work iMac” into the Title field.
  4. Paste your key into the Key field (it has already been copied to your clipboard).
  5. Click Add Key.
  6. Enter your Github password.

Now let’s test that it all worked.

Congratulations!

Your Mac is now up and running with both Git and Github. I intend to write another post about some of the commonly used commands I always find myself looking up syntax for, as well as those that members on the team had to learn in order to effectively take part in the production process.

Recommended tools

Text Editors

If you’re just getting your feet wet with writing code, you’ll want to look into a text editor that is purpose built for that task.

My hardcore colleagues wouldn’t leave me alone if I didn’t also mention command-line editors like Vim and Emacs, but I’d recommend one of the previously listed apps for getting started.

I don’t recommend using TextEdit as it doesn’t offer syntax highlighting, and I’m personally not fond of Dreamweaver for writing code as I feel it allows its WYSIWYG mode to be used as a crutch. That said, Dreamweaver’s predecessor4 in Adobe’s product lineup was what I learned to write HTML on, so there’s that.

Generate Ssh Key Github

However with the explosion of online code teaching platforms out there (and Firebug/DOM inspector tools), I don’t see the need to use a WYSIWYG editor anymore.

Git GUI Tools

When I first started dabbling with Git, I used the popular Tower app to manage my repositories. It has a fantastic interface and offers most of the features of the command line app.

However when we began this endeavor at my past job, the development team and I wanted to ensure that all persons with access to the codebase thought about what the actions they were going to take, and deliberately execute commands.

GUI tools are great, but they can sometimes allow disastrous things to happen with the push of a button. Additionally they can abstract away the syntax of the language/protocol they are built upon, and as a result leave users dependent on the GUI rather than knowledgeable about the underlying technology.

Generate Ssh Key Github Windows

If you must use a GUI tool, by all means do. However in the circumstances I mentioned, it wasn’t an option we wanted to offer.

Terminal Configuration

I’ve been enjoying iTerm2 for a few small perks it offers, mainly the ability to have perfect representation of the Solarized Dark theme.

Feedback

If there are any steps/instructions I’ve written that have been outdated by newer information/technology, are simply wrong, or could be explained better please feel free to contact me on Twitter where I’m @burnedpixel.

  1. The stack for this project was very complicated and resulted in us using Vagrant and VirtualBox to literally get virtual instances of the dev environment going on each workstation.↩

  2. I had hosted the appropriate DMGs for the 10.7 and 10.8 tools on a local fileserver to speed up this step. Unfortunately the general public will have to go to Apple’s developer site, sign up for a free account, and download the tools from there.↩

  3. Security settings adjustment to install Git:

    • Go to Apple Menu > System Preferences
    • Click Security & Privacy
    • Click the lock icon in the bottom left and enter your account password
    • Select “Anywhere” for the “Allow applications downloaded from” setting
    • Close System Preferences
  4. While I may have been exposed to making web pages by software like Claris Home Page and Microsoft FrontPage, I really learned to write HTML by hand from a software suite called GoLive Cyberstudio. In what has now become a familiar process, Adobe bought GoLive out so they could integrate Cyberstudio into their product lineup. In what has now also become familiar, Cyberstudio (simply rebranded as GoLive) rarely got any updates and lived a deprecated existence until it’s death nearly 10 years later.↩