Nos movemos al directorio raíz del usuario root
$ cd /root/
Creamos la carpeta .ssh
$ mkdir .ssh
$ cd .ssh
Creamos una llave de identificación:
$ ssh-keygen
Le llamaremos bitbucket
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): bitbucket
Cuando vea este mensaje presione Enter
Enter passphrase (empty for no passphrase):
Luego verá el siguiente mensaje y también presione Enter
Enter same passphrase again:
Si todo salió bien entonces verá un mensaje como este:
Your identification has been saved in bitbucket.
Your public key has been saved in bitbucket.pub.
The key fingerprint is:
15:cc:c3:99:9c:3a:a4:5a:f9:b9:b7:78:65:cd:80:92 root@CentOS01
The key's randomart image is:
+--[ RSA 2048]----+
| =.+ |
| . X. |
| + o.o |
| + E.. . |
| o .S+ + |
| . o o o |
| . o |
| ..o |
| .o.. |
+-----------------+
Creamos el archivo de configuración SSH
$ vi config
Ahí guardaremos el contenido siguiente:
Host bitbucket.org
IdentityFile ~/.ssh/bitbucket
Actualizamos el archivo .bashrc
$ vi ~/.bashrc
Ahí guardaremos el contenido siguiente:
SSH_ENV=$HOME/.ssh/environment
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add
}
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
Instalamos la llave pública en Bitbucket, para ver el contenido de la llave pública ejecutamos el comando siguiente
$ cat ~/.ssh/bitbucket.pub
Ese contenido lo guardamos en el url de su repositorio:
https://bitbucket.org/teamSER/[nombre-del-repositorio-aqui]/admin/deploy-keys
Ver imagen de ejemplo:
Para comprobar que todo anda bien ejecutamos el comando siguiente:
$ ssh -T git@bitbucket.org
Ya con esto fácilmente podremos hacer git clone vía ssh sin que el git pull este solicitando autenticación.
Fuente: https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git