Use Git + SSH to do authentication - #2
Conversation
|
Sebastian, this is a great PR and very relevant, thank you. Dockerize was created to simplify the interaction between Jenkins and Docker, in a continuous delivery environment. There are a few blog posts which go into more depth, but this one explains the whole setup best. In my experience, using application tokens for Jenkins when integrating with github is a lot more straightforward than setting up the Jenkins user with an SSH key. Your use-case is a different one, but just as valid. I will definitely merge this in, let me just make a few code suggestions first. |
There was a problem hiding this comment.
I don't think that this message is useful for someone that just wants the end-result of this command. It's a detail which is relevant for the developer, sure, so a comment would be more appropriate IMO.
There was a problem hiding this comment.
I agree. Couldn't manage to have ssh not print the message down below. That's why I had this message. Any idea how to get this to go to /dev/null?
Pseudo-terminal will not be allocated because stdin is not a terminal.
Hi sourishkrout! You've successfully authenticated, but GitHub does not provide shell access.
Skipping github credentials. Using ssh agent instead.
There was a problem hiding this comment.
I've only just noticed that you're checking for the exit code to be 1. The only successful error code is 0, so anything else points to an error. In this specific case, GitHub is saying that it doesn't allow shell access. Using 1 for the exit code is appropriate as given the ssh command, one would expect a TTY. I think this is more robust:
github_ssh_connection="$(ssh -Aq -o BatchMode=yes -o ConnectTimeout=1 git@github.com 2>&1)"
if [[ $github_ssh_connection =~ "successfully authenticated" ]]
then
# ...
fi|
Thank you for your feedback! I'll push a consolidated diff once I'll hear back from you on my questions. |
Really love dockerize! Nice work. :-)
We're exclusively relying on SSH to authenticate (agent forwarding) with github to avoid having to keep credentials stored persistently on remote servers. I've added a bunch of code to check for ssh auth first before going down the road of using credentials.
I'm not very good at shell scripting so any pointers are appreciated. I'd love to see git/ssh support merged eventually though.
Please let me know.
Sebastian