Skip to content

Instantly share code, notes, and snippets.

@samrocketman
Last active December 27, 2015 02:59
Show Gist options
  • Save samrocketman/7255904 to your computer and use it in GitHub Desktop.
Save samrocketman/7255904 to your computer and use it in GitHub Desktop.
/etc/ssh/sshd_config append to disable password auth for SSH on the git user only.
Match User git
PasswordAuthentication no
@samrocketman
Copy link
Author

I added the following...

Match User git
    PasswordAuthentication no
    Banner "/home/git/ssh-banner.txt"

Where the contents of ssh-banner.txt is...

Did you add your SSH key to your gitlab user?

@findel
Copy link

findel commented Nov 4, 2013

I like the above idea:

Banner "/home/git/ssh-banner.txt"

But it shows the banner every time you git push or git pull - not only when the user hasn't got an SSH key setup.

@samrocketman
Copy link
Author

@findel unfortunately that's a limitation in SSHD... for now I don't know of a good work around to that. I decided it was better to show it every time in my setup so that users at least get a hint of where they need to go without asking anybody. But I agree it's not ideal. For details see Banner in sshd_config(5) man page.

@samrocketman
Copy link
Author

@findel perhaps it would be better to state something like this in the banner...

GitLab SSH Key Access: If you get permission denied then make sure you added your SSH key to your gitlab user.
See [insert your help doc here]

@samrocketman
Copy link
Author

I just realized a better solution would be to use pam_auth to give a message on password only. Perhaps there's a way to do it on password failure only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment