Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
A short manual on SSH + GitHub & BitBucket (on Win, almost the same on Lin)
First you need to find the keys
$ ls -al ~/.ssh
# Спискок файлов в директории .ssh, если они есть
# id_rsa.pub # Нам интересны эти два брата, точнее этот публичный код (паб)
# id_rsa # Это для сверки с пабом
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
# Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
# Enter passphrase (empty for no passphrase):
# Enter same passphrase again:
$ ssh-keygen -p # Введете старый, а потом новый.
# Your identification has been saved in /Users/you/.ssh/id_rsa.
# Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected]
$ ssh-agent -s
Agent pid 59566
$ eval $(ssh-agent -s)
Agent pid 59566
$ ssh-add ~/.ssh/id_rsa
$ ssh -T [email protected]
Host bitbucket.org
IdentityFile ~/.ssh/id_rsa # Тут приватный ключ!
$ ssh -T [email protected]
Hi #{username}! You've successfully authenticated, but GitHub does not provide shell access.
conq: logged in as tutorials.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
Thу authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is 12:12:12...12.
Are you sure want to conecting (yes/no)?
$ ssh -T [email protected]
If you work with Sourcetree (I recommend for Windows), then there is such a moment that the program does not accept the standard format of these keys and in order to work with the program via ssh, you will have to generate them from the received key (private) in a different format understandable by putty. To do this, use the puttygen program. Which is included in the supply of Sourcetree.
# Note: ~/.ssh/environment should not be used, as it
# already has a different purpose in SSH.
env=~/.ssh/agent.env
# Note: Don't bother checking SSH_AGENT_PID. It's not used
# by SSH itself, and it might even be incorrect
# (for example, when using agent-forwarding over SSH).
agent_is_running() {
if [ "$SSH_AUTH_SOCK" ]; then
# ssh-add returns:
# 0 = agent running, has keys
# 1 = agent running, no keys
# 2 = agent not running
ssh-add -l >/dev/null 2>&1 || [ $? -eq 1 ]
else
false
fi
}
agent_has_keys() {
ssh-add -l >/dev/null 2>&1
}
agent_load_env() {
. "$env" >/dev/null
}
agent_start() {
(umask 077; ssh-agent >"$env")
. "$env" >/dev/null
}
if ! agent_is_running; then
agent_load_env
fi
# if your keys are not stored in ~/.ssh/id_rsa or ~/.ssh/id_dsa, you'll need
# to paste the proper path after ssh-add
if ! agent_is_running; then
agent_start
ssh-add
elif ! agent_has_keys; then
ssh-add
fi
unset env
$ git remote -v
. To change git addresses, there is a special command: $ set-url
, enter the following:$ git remote set-url origin [email protected]:USERNAME/OTHERREPOSITORY.git
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question