Skip to content

Instantly share code, notes, and snippets.

@kevinrodbe
Last active May 20, 2021 00:30
Show Gist options
  • Save kevinrodbe/c4d94adc81bb1ea901c31b3400114021 to your computer and use it in GitHub Desktop.
Save kevinrodbe/c4d94adc81bb1ea901c31b3400114021 to your computer and use it in GitHub Desktop.
Configurar Git SSH Key en windows
# Dentro de C:\Users\myUser\.profile
env=~/.ssh/agent.env
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }
agent_load_env
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
agent_start
ssh-add
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
ssh-add
fi
unset env

Ve a (Recomendado):

C:\Users\myUser\.ssh

1.- Crear SSH Key.

ssh-keygen -t rsa -b 4096 -C "[email protected]"

2.- Inicializa SSH Agent

eval $(ssh-agent -s)

3.- Agrega tu SSH Key a SSH Agent

ssh-add ~/.ssh/myKey

Por defecto el nombre es id_rsa; sino, usa el nombre que definiste durante el paso 1

4.- Agregar tu SSH Key (el que tiene la extensión .pub) a tu cuenta de Github/Bitbucket

5.- Crea el archivo .profile

6.- Crea/Modifica el archivo config

# Dentro de C:\Users\myUser\.ssh\config
# Debes poner el nombre de tu key en MYKEY
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/MYKEY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment