Strona 1 z 1

klucze ssh - używanie różnych kluczy

: 09 lut 2017, 02:46
autor: JoShiMa
Mam pytanie. Generując klucze ssh teoretycznie moge ich wygenerowac kilka kompletów podając podczas generowania lokalizację, gdzie mają zostac umieszczone. Domyślnie to jest .ssh/id_rsa

Wygenerowałam w ten sposób klucz, połączyłam się gitem z repozytorium za pomoca tego klucza i pięknie działa. Poblem w tym, ze na tym samym serwerze (bitbucket) mam jeszcze jedno konto do którego też się chcę łączyć, ale nie mogę użyć tego samego klucza ssh. Jak tworze klucz w innym pliku i go dodaję do profilu na bitbucket to niestety nie działa mi to połączenie. Jak to rozwiązać?

Re: klucze ssh - używanie różnych kluczy

: 17 lut 2017, 21:49
autor: mario_7
Wskazałeś w połączeniu SSH aby skorzystał z innego klucza niż domyślny?
Można to też ustawić w pliku konfiguracyjnym SSH.

Re: klucze ssh - używanie różnych kluczy

: 18 lut 2017, 05:48
autor: jacekalex
man ssh_config pisze:IdentityFile
Specifies a file from which the user's DSA, ECDSA, Ed25519 or RSA
authentication identity is read. The default is ~/.ssh/identity
for protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa,
~/.ssh/id_ed25519 and ~/.ssh/id_rsa for protocol version 2.
Additionally, any identities represented by the authentication
agent will be used for authentication unless IdentitiesOnly is
set. If no certificates have been explicitly specified by
CertificateFile, ssh(1) will try to load certificate information
from the filename obtained by appending -cert.pub to the path of
a specified IdentityFile.

The file name may use the tilde syntax to refer to a user's home
directory or one of the following escape characters: ‘%d’ (local
user's home directory), ‘%u’ (local user name), ‘%l’ (local host
name), ‘%h’ (remote host name) or ‘%r’ (remote user name).

It is possible to have multiple identity files specified in con‐
figuration files; all these identities will be tried in sequence.
Multiple IdentityFile directives will add to the list of identi‐
ties tried (this behaviour differs from that of other configura‐
tion directives).

IdentityFile may be used in conjunction with IdentitiesOnly to
select which identities in an agent are offered during authenti‐
cation. IdentityFile may also be used in conjunction with
CertificateFile in order to provide any certificate also needed
for authentication with the identity.
RTFM:

Kod: Zaznacz cały

man ssh_config

Przykład konfigu dla konkretnego hosta:
Host abw
Protocol 2
StrictHostKeyChecking yes
ForwardX11 no
Compression yes
BatchMode yes
User root
Port 22
IdentityFile ~/.ssh/abw_rsa
HostName abw.gov.pl
CompressionLevel 9
Potem łączysz się poleceniem:

Kod: Zaznacz cały

ssh abw
Pozdro
:craz: