Я рассмотрел несколько решений этой проблемы, в том числе: https://serverfault.com/questions/515395/gitlab-unable-to-push-via-ssh Gitlab не работает с ключами SSH http://community.bitnami.com/t/unable-to-make-a-ssh-connection-to-gitlab-but-http-push-and-clone-are-working/14939
Хорошо, итак ... Я только что установил GitLab сегодня. Я последовал за это руководство. Когда я дошел до создания пользователя, уже использовался «git», поэтому я решил использовать «gitlab». Если это было плохое решение, я могу вернуться и попытаться посмотреть, что использует «git», и почему, и могу ли я остановить это и передать GitLab.
В основном, когда я нажимаю GitLab, я пытаюсь использовать адрес SSH: gitlab@git.example.com: user / repo. Когда я использую «git push origin master» (с источником, указывающим на вышеупомянутый адрес), меня спрашивают пароль пользователя «gitlab» для SSH-сервера. Если я вхожу в него, GitLab сообщает мне, что «пользователь / репо» не является репозиторием, и затем закрывается.
Вывод «ssh -vvvT»:
C:\Users\Jake>ssh -vvvT gitlab@git.redacted.com
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug2: ssh_connect: needpriv 0
debug1: Connecting to git.redacted.com [redacted] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Jake/.ssh/identity type -1
debug3: Not a RSA1 key file /c/Users/Jake/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug2: key_type_from_name: unknown key type 'Proc-Type:'
debug3: key_read: missing keytype
debug2: key_type_from_name: unknown key type 'DEK-Info:'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /c/Users/Jake/.ssh/id_rsa type 1
debug3: Not a RSA1 key file /c/Users/Jake/.ssh/id_dsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug2: key_type_from_name: unknown key type 'Proc-Type:'
debug3: key_read: missing keytype
debug2: key_type_from_name: unknown key type 'DEK-Info:'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /c/Users/Jake/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubu
ntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-g
roup-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour1
28,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-c
tr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour1
28,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-c
tr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@open
ssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@open
ssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-
sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hel
lman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour12
8,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,ae
s128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndae
l-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour12
8,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,ae
s128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndae
l-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,um
ac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hma
c-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@opens
sh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-1
28@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh
.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,um
ac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hma
c-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@opens
sh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-1
28@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh
.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_init: found hmac-md5
debug1: kex: server->client aes128-cbc hmac-md5 none
debug2: mac_init: found hmac-md5
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 119/256
debug2: bits set: 524/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /c/Users/Jake/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug3: check_host_in_hostfile: filename /c/Users/Jake/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug1: Host 'git.majornoob.com' is known and matches the RSA host key.
debug1: Found key in /c/Users/Jake/.ssh/known_hosts:1
debug2: bits set: 515/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /c/Users/Jake/.ssh/identity (0x0)
debug2: key: /c/Users/Jake/.ssh/id_rsa (0xa01b360)
debug2: key: /c/Users/Jake/.ssh/id_dsa (0xa01b378)
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /c/Users/Jake/.ssh/identity
debug3: no such identity: /c/Users/Jake/.ssh/identity
debug1: Offering public key: /c/Users/Jake/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: /c/Users/Jake/.ssh/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
gitlab@git.redacted.com's password:
C:\Users\Jake>
Кажется, у него проблемы с чтением моего ключа (ключей) SSH? Я не уверен, что происходит.
Я пробовал два разных ключа SSH с двумя разными типами шифрования, используя следующие команды:
ssh-keygen -t rsa -C "redacted@gmail.com"
ssh-keygen -t dsa -C "redacted@gmail.com"
Вот результат, если я попытаюсь нажать, используя протокол SSH:
C:\Users\Jake\Documents\Development\test>git push origin master
gitlab@git.redacted.com's password:
fatal: 'jake/test.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
C:\Users\Jake\Documents\Development\test>
Почему он даже запрашивает пароль SSH? Я хочу использовать ключи.
Ключи находятся в установке GitLab, вот некоторые доказательства:
Я не уверен, что делать дальше и какую еще информацию я могу предоставить, чтобы упростить диагностику моей проблемы. Пожалуйста, помогите мне! Я отвечу на любой ваш вопрос, который может облегчить вам решение этой проблемы.
Заранее спасибо!
редактировать: Когда я использую "ssh -vvvT gitlab@git.redcted.com" и фактически ввожу пароль для пользователя, он показывает мне Ubuntu MOTD. Я почти на 200% уверен, что этого не должно происходить.
Моя ситуация
Сервер: Ubuntu 14.04.1 Обновление до последних версий пакета (sudo apt-get update && sudo apt-get dist-upgrade). Gitlab: 6.9.0 (версия gitlab не имеет значения).
Все работало отлично до обновления и перезагрузки сервера с правильными ключами ssh и всем подобным. Но после обновления пакетов все пользователи были заблокированы для нормальной работы, но запрашивали пароль пользователя «git».
Что я сделал?
Через несколько часов я действительно обнаружил, что произошло на самом деле: новые проверки разрешений на /home/git
каталог при запуске команд git.
Шаги, чтобы проверить, подходит ли он для вашего случая:
tail -f /var/log/auth.log
git remote update
).Authentication refused: bad ownership or modes for directory /home/git
./home/git
: sudo chown git:git /home/git
.sudo chmod 755 /home/git
.git remote update
без каких-либо проблем.Это сработало для меня !!!
Ты прав. MOTD должен не отображаться для любого пользователя. У Gitlab есть собственная встроенная оболочка, которая обрабатывает пользователей, но эта оболочка запускается только тогда, когда пользователь входит в систему со своим закрытым ключом, что для вас не работает. Поскольку при входе в систему как git с паролем открывается приглашение, вам следует удалить пароль для git:
sudo passwd -d git
А затем отключите вход в систему с помощью bash, запустив sudo vim /etc/passwd
найдите пользователя git и в конце, где он говорит /bin/bash
, замените его на /bin/nologin
.
Что касается ключей, убедитесь, что ваш клиентский компьютер может использовать ключи. Попробуйте подключиться к localhost. Он должен запросить пароль. Выйдите из системы, добавьте ключ ssh клиента к себе с помощью:
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys #This should not require root
Затем попробуйте снова войти на localhost. Если он не запрашивает пароль, вы знаете, что ваш клиент настроен правильно.
Если с вашим клиентом все в порядке, попробуйте отладить сервер. ПЕРЕД вы делаете это, удаляете свои ключи со скриншота. Затем убедитесь, что Gitlab имеет полный доступ к каталогу /home/git/.ssh, запустив sudo chmod -R git /home/git/.ssh
. Повторно добавьте свои ключи, а затем запустите sudo cat /home/git/.ssh/authorized_keys
и посмотрите, есть ли там ваши ключи.
Если это не сработает, проверьте журналы gitlab, запустив tailf /home/git/gitlab/{LOG}.log
а затем заменить {LOG}
с участием unicorn
, application
, production
, или githost
, затем попробуйте добавить свои ключи.
ПОМНИТЕ удалить свои ключи, прежде чем что-либо делать. Ключи хранятся в базе данных и должны храниться в /home/git/.ssh/authorized_keys. Если они есть в базе данных, но не в файле, могут возникнуть проблемы.