Usando chaves SSH diferentes do padrão no Mac OS

Ao tentar usar chaves SSH diferentes das padrão (id rsa e id dsa), para conectar-se a github.com ou bitbucket.org, encontrei um problema que fazia com que o Mac OSX sempre exibisse a caixa de diálogo de senha longa, mas nunca aceitando o senha longa.

Descobri que, para resolver isso, precisava fazer 2 coisas:

1 – Crie um par de chaves SSH com uma senha, ou seja, não em branco
2 – Adicione a senha ao Keychain via ssh-add

Aqui está o que eu fiz:

~ > cd .ssh
.ssh > ssh-keygen -C "e@mail.com"

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/you/.ssh/id_rsa): id_rsa.github
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.github.
Your public key has been saved in id_rsa.github.pub.
The key fingerprint is:
ff
:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff e@mail.com
The key's randomart image is:
+--[ RSA 2048]----+

|.................|

|.................|

|.................|

|.................|

|.................|

|.................|

|.................|

|.................|

|.................|

+-----------------+

Para adicionar a senha longa ao Keychain:

.ssh > ssh-add -K id_rsa.github
Enter passphrase for id_rsa.bitbucket:
Passphrase stored in keychain: id_rsa.github
Identity added: id_rsa.github (id_rsa.github)

Além disso, certifique-se de definir as permissões corretas para a chave:

.ssh > chmod 600 id_rsa.github.pub

Nota: as informações pessoais foram ‘ofuscadas’ 🙂