Генерируем ключ:
$ cd ~/.ssh/ $ ssh-keygen -t rsa -C "[email protected]" Generating public/private rsa key pair. Enter file in which to save the key (/home/setevoy/.ssh/id_rsa): setevoy_github_openssh Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in setevoy_github_openssh. Your public key has been saved in setevoy_github_openssh.pub. The key fingerprint is: 1b:d3:13:10:52:5f:31:80:98:c9:82:94:1f:7c:79:64 [email protected] The key's randomart image is: +--[ RSA 2048]----+ | ..+ ..BEo..+. | | o + Booo . . | | . + . o | | . . . | | S o | | + . | | . | | | | | +-----------------+
Проверяем:
[simterm]
$ ls -l | grep github -rw------- 1 setevoy setevoy 1679 тра 31 11:18 setevoy_github_openssh -rw-r--r-- 1 setevoy setevoy 407 тра 31 11:18 setevoy_github_openssh.pub
[/simterm]
Проверяем доступ сейчас:
[simterm]
$ ssh -T [email protected] Permission denied (publickey).
[/simterm]
Переходим в настройки аккаунта:
Переходим в SSH and GPG keys:
Жмём New SSH key и добавляем ключ:
[simterm]
$ cat setevoy_github_openssh.pub ssh-rsa AAAAB***wpBDlz [email protected]
Вводим пароль – и ключ добавлен:
Запускаем ssh-agent
:
[simterm]
$ eval “$(ssh-agent -s)”
[/simterm]
(тут simterm
коверкает кавычки – поменяйте на обычные “”)
Добавляем ключ:
[simterm]
$ ssh-add /home/setevoy/.ssh/setevoy_github_openssh
Identity added: /home/setevoy/.ssh/setevoy_github_openssh (/home/setevoy/.ssh/setevoy_github_openssh)
[/simterm]
Проверяем:
[simterm]
$ ssh -T [email protected] Hi username! You've successfully authenticated, but GitHub does not provide shell access.
[/simterm]
И ещё раз – клонируем репозиторий:
[simterm]
$ git clone [email protected]:project/project_house.git Cloning into 'project_house'... Warning: Permanently added the RSA host key for IP address '192.***.***.130' to the list of known hosts. remote: Counting objects: 249, done. remote: Compressing objects: 100% (203/203), done. remote: Total 249 (delta 41), reused 249 (delta 41), pack-reused 0 Receiving objects: 100% (249/249), 6.26 MiB | 3.08 MiB/s, done. Resolving deltas: 100% (41/41), done. Checking connectivity... done.
[/simterm]
Создаём бранч:
[simterm]
$ git checkout -b develop Switched to a new branch 'develop'
[/simterm]
И пушим его обратно:
[simterm]
$ git push -u origin develop Total 0 (delta 0), reused 0 (delta 0) To [email protected]:project/project_house.git * [new branch] develop -> develop Branch develop set up to track remote branch develop from origin.
[/simterm]
Что бы не вызывать ssh-agent
и не добавлять ключ каждый раз при старте новой сессии – в в конец файла ~/.bashrc
добавляем:
# start ssh { eval $(ssh-agent -s) && ssh-add /home/setevoy/.ssh/setevoy_github_openssh; } &> /dev/null
Готово.