GitLab SSH k

65 views
Skip to first unread message

Ashwini

unread,
Oct 15, 2016, 2:00:26 AM10/15/16
to GitLab
Hi,

How to get user and SSH key information using the SSH key finger print in Gitlab

thanks
Ashwini

Aleksey Tsalolikhin

unread,
Oct 15, 2016, 9:55:37 AM10/15/16
to gitl...@googlegroups.com
GitLab stores SSH keys in the file .ssh/authorized_keys  in the account of the "git" user.

For example, I just spun up a GitLab CE instance and added an SSH key:

root@6986745c-ccbd-42ac-9498-deb8b37541d7:/var/opt/gitlab/.ssh# more authorized_keys
command="/opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell key-1",no-po
rt-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaC1yc
2EAAAADAQABAAABAQDZuLDgFDf6Bgezk6nxS7QoRNtm3OiJWezm1/uJPxHqJKHJiiLhl0Iy400sSLzwL
EOAX0kQgHQ0XAtYjRd35+qzncU1mz07H4vxPD/VnQjY9M/74Xn8Qr3Jeuz4wI8zM4bBB9YGTab8Stao+
wKpuwXVZf9pQpV9PbeHEE2f+0tl/adwY3uBujXzbC+anwiksnuF80vld4veI4HOAWC+V7qjvGixa7pFC
XrUhRCw0DUBB85tcPH9qO7uC8dqrR8grPx6W37gav4nHmVv0eZNd6xVY4xEI6E+iXtKTvt9r35oIzoXM
SyPavSsI7nmtcY56Ya6fWQr7SFR1a3uLJzAxoy/
root@6986745c-ccbd-42ac-9498-deb8b37541d7:/var/opt/gitlab/.ssh# 

Now let's take a peek in the database to see how keys are mapped to users:

root@6986745c-ccbd-42ac-9498-deb8b37541d7:~# su - gitlab-psql
$ /opt/gitlab/embedded/bin/psql --port 5432 -h /var/opt/gitlab/postgresql -d gitlabhq_production
psql (9.2.18)
Type "help" for help.

gitlabhq_production=# \x
Expanded display is on.
gitlabhq_production=# select * from keys;
-[ RECORD 1 ]---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
id          | 1
user_id     | 1
created_at  | 2016-10-15 13:43:43.871878
updated_at  | 2016-10-15 13:43:43.871878
key         | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZuLDgFDf6Bgezk6nxS7QoRNtm3OiJWezm1/uJPxHqJKHJiiLhl0Iy400sSLzwLEOAX0kQgHQ0XAtYjRd35+qzncU1mz07H4vxPD/VnQjY9M/74Xn8Qr3Jeuz4wI8zM4bBB9YGTab8Stao+wKpuwXVZf9pQpV9PbeHEE2f+0tl/adwY3uBujXzbC+anwiksnuF80vld4veI4HOAWC+V7qjvGixa7pFCXrUhRCw0DUBB85tcPH9qO7uC8dqrR8grPx6W37gav4nHmVv0eZNd6xVY4xEI6E+iXtKTvt9r35oIzoXMSyPavSsI7nmtcY56Ya6fWQr7SFR1a3uLJzAxoy/ atsaloli@tashkent
title       | atsaloli@tashkent
type        | 
fingerprint | f2:c7:fe:89:f0:63:71:9e:8a:67:a9:49:a0:a4:99:2b
public      | f

gitlabhq_production=# select id, username from users;
-[ RECORD 1 ]--
id       | 1
username | root

gitlabhq_production=# 

So there you go, you've got the key, the key title, and the user it belongs to (root).

Hope this helps,
Aleksey Tsalolikhin
Vertical Sysadmin, Inc.
Authorized GitLab Training Partner



-- 
Need training on CFEngine, Git or Time Management?  Email trai...@verticalsysadmin.com.

--
You received this message because you are subscribed to the Google Groups "GitLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gitlabhq+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gitlabhq/38ebf8ea-bead-4e02-9952-a5f5b090db09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages