Creative technologist with foodie tendencies. Life-long geek. Put-in-Bay native living in Cleveland. +3 boys and their amazing mother.

 

uxrave:

Seth Godin with some wise words on the importance of courage, curiosity, and iteration.

uxrave:

Seth Godin with some wise words on the importance of courage, curiosity, and iteration.

All my favs, including Ze! Why The World Is Awesome in 60 Facts - Geek Week Special - Earth Unplugged (by Earth Unplugged)

Automating SSH Password Login for Windows with Git

OK I use both OS X and Windows and where OS X (and Linux for that matter) work pretty flawlessly to establish your password for pushing fetching/pushing to remotes like Github and BitBucket, Windows is not so forgiving.

To be sure, you can use a program like the wonderful (and free) SourceTree app from Atlassian, it is not without it’s little gotchas (more on that later).

For now let is assume you are using MySysGit for Windows and have even added it to your context menu.

If you want to use SSH, it really isn’t that hard. You only need to generate an SSH key (using PuTTY for instance) and add it Github or BitBucket.

The trouble is, while this works, it is no less of a hassle than using HTTPS since for every push you make, you must retype your password (Stings doesn’t it? ;)

Github has a nice little guide on how to get around this (sort of) by launching ssh-agent automatically whenever you launch GitBash. This way you need enter your password only once per session.

To simplify this process, just follow these steps:

1. Add a “.profile” file to your user folder (e.g. C:\users\yourusername.yourdomain) folder 

One gotcha is that Windows won’t just let you add an extension only file to a folder. You can get around this by browsing to the folder via command prompt and typing “touch .profile” or by creating a simple text file, opening it in Notepad and adding quotes around the file name (like this -> “.profile”) when choosing save. The latter has the advantage that you can paste the following lines in and be ready to go in one quick step.

2. Add these lines to the “.profile” file in your user folder

SSH_ENV="$HOME/.ssh/environment"

# start the ssh-agent
function start_agent {
    echo "Initializing new SSH agent..."
    # spawn ssh-agent
    ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
    echo succeeded
    chmod 600 "$SSH_ENV"
    . "$SSH_ENV" > /dev/null
    ssh-add
}

# test for identities
function test_identities {
    # test whether standard identities have been added to the agent already
    ssh-add -l | grep "The agent has no identities" > /dev/null
    if [ $? -eq 0 ]; then
        ssh-add
        # $SSH_AUTH_SOCK broken so we start a new proper agent
        if [ $? -eq 2 ];then
            start_agent
        fi
    fi
}

# check for running ssh-agent with proper $SSH_AGENT_PID
if [ -n "$SSH_AGENT_PID" ]; then
    ps -f -u $USERNAME | grep "$SSH_AGENT_PID" | grep ssh-agent > /dev/null
    if [ $? -eq 0 ]; then
  test_identities
    fi
# if $SSH_AGENT_PID is not properly set, we might be able to load one from
# $SSH_ENV
else
    if [ -f "$SSH_ENV" ]; then
  . "$SSH_ENV" > /dev/null
    fi
    ps -f -u $USERNAME | grep "$SSH_AGENT_PID" | grep ssh-agent > /dev/null
    if [ $? -eq 0 ]; then
        test_identities
    else
        start_agent
    fi
fi

Tip: If you don’t use the default key names, or you store your keys in a different path, you will need to add the path to the ssh-add line so that ssh knows where to find your key.

Now when you open GitBash, you will be prompted for your password once and can git push and git pull all day long.

NOTE: If you are using SourceTree and you get an error that says it can’t load your private key, browse to your .ssh folder (typically in your user folder) and copy the id_rsa file (or whatever your extensionless SSH key is called) and give it a “.ppk” extension. Shutdown SourceTree and be sure to close Pageant in your system tray. Restart SourceTree and choose Tools -> Launch SSH Agent… which will launch Pageant. Choose Add Key and browse to the .ppk file you just created. This should fix the problem. 

Users Don't Scroll! ...and Other UX Myths

Here’s the link to the presentation I gave at the Pittsburgh Tech Fest 2013. Enjoy!