Модераторы: powerfox, ZeeLax
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Авторизация по ключу, не пускает 
V
    Опции темы
Shogun
Дата 9.7.2011, 14:48 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


сёгун-сан
**


Профиль
Группа: Участник
Сообщений: 290
Регистрация: 8.6.2006
Где: Кишинёв

Репутация: нет
Всего: 11



Добрый всем день!

Вроде все делаю по фэншую но все-равно не пускает   smile smile 

Ubuntu 10.10

Что делаю:

1. Создаю нового пользователя в системе
Код

sudo adduser --system --shell /bin/sh --gecos 'git version control' --group --disabled-password --home /home/git git

2. Создаю для него .ssh и .ssh/authorized_keys
Код

su git
cd /home/git
mkdir .ssh
chmod 700 .ssh
cd .ssh
touch authorized_keys
chmod 600 authorized_keys

3. Для своего пользователя создаю ключи без пароля
Код

ssh-keygen -t rsa

4. Копирую публичный ключ пользователю гит
Код

sudo cp /home/shogun/.ssh/id_rsa.pub /home/git/.ssh/shogun.pub

5. Добавляю ключ в authorized_keys
Код

cd /home/git/.ssh
cat shogun.pub >> authorized_keys

6. Делаю рестарт ssh сервиса, не уверен нужно это или нет но...
Код

sudo service ssh restart

7. Пытаюсь подключится
Код

ssh git@localhost

а он мне в ответ требует пароль... ((

короткий дебаг
Код

OpenSSH_5.5p1 Debian-4ubuntu5, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to localhost [::1] port 22.
debug1: Connection established.
debug1: identity file /home/shogun/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/shogun/.ssh/id_rsa-cert type -1
debug1: identity file /home/shogun/.ssh/id_dsa type -1
debug1: identity file /home/shogun/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-4ubuntu5
debug1: match: OpenSSH_5.5p1 Debian-4ubuntu5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.5p1 Debian-4ubuntu5
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'localhost' is known and matches the RSA host key.
debug1: Found key in /home/shogun/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/shogun/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/shogun/.ssh/id_dsa
debug1: Next authentication method: password
git@localhost's password: 

Вроде все проходит нормально и даже ключ проходит(ssh_rsa_verify: signature correct), но потом Roaming not allowed by server, может и за этого, гугл не помог.


Помогите пожалуйста, целый день на этом потерял. smile 

Спасибо.



Это сообщение отредактировал(а) Shogun - 9.7.2011, 14:50


--------------------
2b || !2b
PM MAIL ICQ Skype   Вверх
bilbobagginz
Дата 9.7.2011, 23:17 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Naughtius Maximus
****


Профиль
Группа: Экс. модератор
Сообщений: 8813
Регистрация: 2.3.2004
Где: Israel

Репутация: 34
Всего: 317



рекомендую, параллельно с попыткой входа по ключу посмотреть в /var/log/auth.log.
судя по команде:
Код

su git

в переходе на другого пользователя возможно файлы создаваемые позже будут принадлежать оригинальному пользователю, а на git.
проверить:
кому принадлежат каталоги:
  • /home/git
  • /home/git/.ssh (и файлы внутри)

надо, чтобы принадлежали git-у.



--------------------
Я ещё не демон. Я только учусь.
PM WWW   Вверх
Shogun
Дата 9.7.2011, 23:59 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


сёгун-сан
**


Профиль
Группа: Участник
Сообщений: 290
Регистрация: 8.6.2006
Где: Кишинёв

Репутация: нет
Всего: 11



bilbobagginz, проверил конечно, все ему принадлежит.


--------------------
2b || !2b
PM MAIL ICQ Skype   Вверх
ChihPih
Дата 10.7.2011, 07:28 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 532
Регистрация: 3.12.2006

Репутация: 5
Всего: 22



Цитата(Shogun @  9.7.2011,  17:48 Найти цитируемый пост)
6. Делаю рестарт ssh сервиса, не уверен нужно это или нет но...Без подсветки1:sudo service ssh restart

Рестарт сервиса делать не обязательно...
Конфиг SSH покажите.


--------------------
www.info-x.org - информационный ресурс о ОС FreeBSD. Форум.
PM MAIL WWW Jabber   Вверх
Shogun
Дата 10.7.2011, 12:33 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


сёгун-сан
**


Профиль
Группа: Участник
Сообщений: 290
Регистрация: 8.6.2006
Где: Кишинёв

Репутация: нет
Всего: 11



Код

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile    %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords yes

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

#Limit SFTP access to only user home directory
#Match Group sftponly
#ChrootDirectory /home/%u
#ForceCommand internal-sftp
#AllowTcpForwarding no




--------------------
2b || !2b
PM MAIL ICQ Skype   Вверх
ChihPih
Дата 10.7.2011, 13:36 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 532
Регистрация: 3.12.2006

Репутация: 5
Всего: 22



Цитата(Shogun @  10.7.2011,  15:33 Найти цитируемый пост)
AuthorizedKeysFile    %h/.ssh/authorized_keys

Попробуйте так:
Код

AuthorizedKeysFile    .ssh/authorized_keys

И отключите UsePAM:
Код

UsePAM no

Чтобы вообще отключить вход по паролям (на время тестирования).


--------------------
www.info-x.org - информационный ресурс о ОС FreeBSD. Форум.
PM MAIL WWW Jabber   Вверх
Shogun
Дата 10.7.2011, 18:29 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


сёгун-сан
**


Профиль
Группа: Участник
Сообщений: 290
Регистрация: 8.6.2006
Где: Кишинёв

Репутация: нет
Всего: 11



Цитата(ChihPih @  10.7.2011,  13:36 Найти цитируемый пост)
Цитата(Shogun @  10.7.2011,  15:33 Найти цитируемый пост)
AuthorizedKeysFile    %h/.ssh/authorized_keys

Попробуйте так:
Выделить всёБез подсветки
1:
    
AuthorizedKeysFile    .ssh/authorized_keys

И отключите UsePAM:
Выделить всёБез подсветки
1:
    
UsePAM no

Чтобы вообще отключить вход по паролям (на время тестирования). 

Все также. (( 


--------------------
2b || !2b
PM MAIL ICQ Skype   Вверх
bilbobagginz
Дата 10.7.2011, 20:01 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Naughtius Maximus
****


Профиль
Группа: Экс. модератор
Сообщений: 8813
Регистрация: 2.3.2004
Где: Israel

Репутация: 34
Всего: 317



Shogun, вы в дневниках СЕРВЕРА смотрели ? 
напр. в /var/log/auth.log что записывается в процессе подключения ?



--------------------
Я ещё не демон. Я только учусь.
PM WWW   Вверх
Shogun
Дата 10.7.2011, 20:17 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


сёгун-сан
**


Профиль
Группа: Участник
Сообщений: 290
Регистрация: 8.6.2006
Где: Кишинёв

Репутация: нет
Всего: 11



Цитата(bilbobagginz @  10.7.2011,  20:01 Найти цитируемый пост)
Shogun, вы в дневниках СЕРВЕРА смотрели ? 
напр. в /var/log/auth.log что записывается в процессе подключения ?

Да в него ничего и не пишется, видимо лог отключен для этого, не знаю если честно.


--------------------
2b || !2b
PM MAIL ICQ Skype   Вверх
ChihPih
Дата 10.7.2011, 20:29 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 532
Регистрация: 3.12.2006

Репутация: 5
Всего: 22



Цитата(Shogun @ 10.7.2011,  21:29)
Цитата(ChihPih @  10.7.2011,  13:36 Найти цитируемый пост)
Цитата(Shogun @  10.7.2011,  15:33 Найти цитируемый пост)
AuthorizedKeysFile    %h/.ssh/authorized_keys

Попробуйте так:
Выделить всёБез подсветки
1:
    
AuthorizedKeysFile    .ssh/authorized_keys

И отключите UsePAM:
Выделить всёБез подсветки
1:
    
UsePAM no

Чтобы вообще отключить вход по паролям (на время тестирования). 

Все также. ((

Так не должно быть, сервер должен выдавать ошибку авторизации с такими параметрами, если публичный ключ не подошел...
Попробуйте тогда еще явно указать:
Код

PasswordAuthentication no



--------------------
www.info-x.org - информационный ресурс о ОС FreeBSD. Форум.
PM MAIL WWW Jabber   Вверх
Shogun
Дата 10.7.2011, 22:22 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


сёгун-сан
**


Профиль
Группа: Участник
Сообщений: 290
Регистрация: 8.6.2006
Где: Кишинёв

Репутация: нет
Всего: 11



Цитата(ChihPih @  10.7.2011,  20:29 Найти цитируемый пост)
Так не должно быть, сервер должен выдавать ошибку авторизации с такими параметрами, если публичный ключ не подошел...
Попробуйте тогда еще явно указать:
Код
PasswordAuthentication no



Код

ssh git@localhost -vv
OpenSSH_5.5p1 Debian-4ubuntu5, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [::1] port 22.
debug1: Connection established.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug2: key_type_from_name: unknown key type '-----END'
debug1: identity file /home/shogun/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/shogun/.ssh/id_rsa-cert type -1
debug1: identity file /home/shogun/.ssh/id_dsa type -1
debug1: identity file /home/shogun/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-4ubuntu5
debug1: match: OpenSSH_5.5p1 Debian-4ubuntu5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.5p1 Debian-4ubuntu5
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-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: [email protected],[email protected],ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],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: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr 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: 115/256
debug2: bits set: 548/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'localhost' is known and matches the RSA host key.
debug1: Found key in /home/shogun/.ssh/known_hosts:1
debug2: bits set: 480/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: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/shogun/.ssh/id_rsa (0x213a9db8)
debug2: key: /home/shogun/.ssh/id_dsa ((nil))
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/shogun/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/shogun/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).




--------------------
2b || !2b
PM MAIL ICQ Skype   Вверх
ChihPih
Дата 11.7.2011, 06:48 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Опытный
**


Профиль
Группа: Участник
Сообщений: 532
Регистрация: 3.12.2006

Репутация: 5
Всего: 22



Запустите в консоле сервер точно так же - в режиме отладки и лог сюда..


--------------------
www.info-x.org - информационный ресурс о ОС FreeBSD. Форум.
PM MAIL WWW Jabber   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Linux/UNIX: Администрирование"
ZeeLax
Imple
nerezus
Этот форум предназначен для решения вопросов по администрации *n?x-систем, в частности по настройке сложных сетей и обслуживанию серверного оборудования.

  • Вы должны соблюдать правила форума.
  • Помните: какой вопрос, такой и ответ. Прежде чем задать вопрос прочитайте вот эту статью на форуме CIT.
  • Оскорблять запрещается.
  • Религиозные войны в Религиозных войнах.
  • Общение "просто так" в Клубе юнуксоидов. В отличие от многих других разделов, здесь разрешается сдержанно оффтопить и юморить в тему.

За интересные статьи, находки, решения, программы и просто реальную помощь будут ставиться + в репу).


В данный момент этот раздел модерируют nerezus, nickless, powerfox, pythonwin, Imple и ZeeLax. Если вы хотите помочь нам, пишите в ПМ и мы обсудим.


Спасибо. И use UNIX or die; С уважением, nerezus, nickless, powerfox, pythonwin, Imple, ZeeLax.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Администрирование *NIX систем | Следующая тема »


 




[ Время генерации скрипта: 0.0591 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.