Сначала вы можете проверить, работает SSH-Agent
и запустить его, если нет:
if ! [ -n "$SSH_AUTH_SOCK" ] ||
! { ssh-add -l &>/dev/null; rc=$?; [ "$rc" -eq 0 ] || [ "$rc" -eq 1 ];}; then
echo "Starting agent..."
eval "$(ssh-agent -s)"
fi
SSH-Add -L
выходит с кодом 1 Если нет идентичностей и с кодом 2, если он не может подключиться к SSH-агенту
.
Затем вы добавляете пароль для ключевого ключа.
ssh-add ~/path/to/keyfile
Вам не нужно копировать ключ ssh, если вам не нравится. Вы можете переслать локальный ключ с помощью -A
-A Enables forwarding of the authentication agent connection. This can also be specified on a per-host basis in a configuration file.
Agent forwarding should be enabled with caution. Users with the ability to bypass file permissions on the remote host (for the agent's UNIX-domain socket) can access the local agent through
the forwarded connection. An attacker cannot obtain key material from the agent, however they can perform operations on the keys that enable them to authenticate using the identities loaded
into the agent.
Я использую его вот так,
ssh -At user@server
или когда-нибудь даже мне нужно перепрыгнуть через другой хост, поэтому я могу запустить его вот так,
ssh -At user@server -- ssh -At user2@server2
Вы можете (и должны) сгенерировать новый ключ ssh на удаленном компьютере и добавить его в github, используя их инструкции:
https://help.github.com/articles/generating-ssh-keys
, затем скопируйте вновь сгенерированный ключ ssh и добавьте его в github.
Ваш локальный ключ не будет затронут.