Skip to content

Instantly share code, notes, and snippets.

@mkczyk
Last active March 27, 2016 16:19
Show Gist options
  • Save mkczyk/0d661ce932be37882f31 to your computer and use it in GitHub Desktop.
Save mkczyk/0d661ce932be37882f31 to your computer and use it in GitHub Desktop.

Konfiguracja

SSH

Generowanie nowego klucza SSH

Potrzebne np. żeby pushować na GitHuba.

ssh-keygen -t rsa -b 4096 -C "email@example.com"
I podać można nową nazwę pliku /c/Users/<username>/.ssh/id_rsa_new

Ręczne startowanie agenta SSH i dodawanie klucza SSH

eval $(ssh-agent -s)
ssh-add /c/Users/Marcin/.ssh/id_rsa_new

https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

Automatyczne startowanie SSH w GIT Bash

env=~/.ssh/agent.env

agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }

agent_start () {
    (umask 077; ssh-agent >| "$env")
    . "$env" >| /dev/null ; }

# 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_load_env
    agent_start
    ssh-add
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
    ssh-add
fi

unset env

https://help.github.com/articles/working-with-ssh-key-passphrases/#auto-launching-ssh-agent-on-git-for-windows

Możemy zmienić linię z ssh-add na
ssh-add ~/.ssh/id_rsa_github
To będzie pytać o hasło (passphrase) przy starcie. Ale wygodniej zmienić domyślne id_rsa na własne (żeby pytało o hasło jak to bedzie konieczne np. przy git pull).

Zamiana domyślnie wczytywanego id_rsa

Utworzyć plik ~/.ssh/config, a w nim konfiuracja
IdentityFile ~/.ssh/id_rsa_new

Wtedy przy git pull będzie pytać o hasło.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment