Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More about ssh keys #99

Open
jennybc opened this issue Oct 14, 2018 · 7 comments
Open

More about ssh keys #99

jennybc opened this issue Oct 14, 2018 · 7 comments

Comments

@jennybc
Copy link
Owner

jennybc commented Oct 14, 2018

Building up to better coverage of ssh keys in general and, specifically, getting git2r to work well. These notes are likely macOS specific.

What keys are currently registered with the ssh agent?

ssh-add -l
ssh-add -L

See the RSA key fingerprint for a local key in order to, say, match it up against a key on GitHub.

ssh-keygen -E md5 -lf /path/to/key

https://stackoverflow.com/questions/9607295/how-do-i-find-my-rsa-key-fingerprint

Probably important, in terms of understanding behaviour I see on my Mac:

OS X users take note that magic passwordless SSH via Keychain is not the same as using ssh-agent.

@jennybc
Copy link
Owner Author

jennybc commented Oct 14, 2018

@jennybc
Copy link
Owner Author

jennybc commented Oct 14, 2018

This allowed me to verify that yes it's the macOS keychain that is managing my ssh key passphrase right now (macOS Mojave 10.14).

Launch Applications > Utilities > Keychain Access. Now search for "ssh" or "id_rsa", etc. The relevant entry for me shows up as an application password for SSH and I can, indeed, verify it's managing the passphrase for the key I use on GitHub.

https://apple.stackexchange.com/questions/265131/recover-ssh-private-key-passphrase-from-keychain

@jennybc
Copy link
Owner Author

jennybc commented Oct 26, 2018

Good way to test the ssh connection and get a passphrase prompt:

https://help.github.com/articles/testing-your-ssh-connection/

@jennybc
Copy link
Owner Author

jennybc commented Nov 8, 2018

@jennybc
Copy link
Owner Author

jennybc commented Nov 8, 2018

@jennybc
Copy link
Owner Author

jennybc commented Jan 10, 2019

I think on macOS, especially if you want git2r to work, you really do need to use ssh-agent. My experiment with not running it is resulting in lots of friction.

https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

Key commands for quick access:

Start the ssh-agent in the background:

eval "$(ssh-agent -s)"

Check if you can access github.com via ssh (can trigger a challenge for ssh passphrase):

@batpigandme
Copy link
Contributor

batpigandme commented Jul 24, 2019

Finally got my usethis::git_sitrep() to return git2r supports SSH: TRUE and wanted to capture it, since it was a weird combination of steps...

Had/have SSH setup with GitHub from terminal (per Happy Git w/ R and GH docs), specified usethis protocol as SSH, working GitHub PAT, ssh-agent enabled etc.

Basically the entire git_sitrep() below, but with git2r supports SSH: FALSE

usethis::git_sitrep()
#> Git user
#> * Name: 'Mara Averick'
#> * Email: 'my email address'
#> * Vaccinated: TRUE
#> usethis + git2r
#> * Default usethis protocol: 'ssh'
#> * git2r supports SSH: TRUE
#> * Credentials: '<usethis + git2r default behaviour>'
#> GitHub
#> * Personal access token: '<found in env var>'
#> * User: 'batpigandme'
#> * Name: 'Mara Averick'

I ultimately found the solution in the git2r release notes here re. no longer supporting SSH transport by default (breaking change for git2r 0.23.0). To enable, you need to install from source.

Though I'd been using the GitHub version, and already libgit2 on my machine (installed using homebrew), this somehow wasn't linking up until I used the suggested:

install.packages('git2r', type='source', configure.vars='autobrew=yes')

This didn't actually reinstall libgit2 from homebrew, though it would have been allowed, if it hadn't been on my computer.

System info:

R version 3.5.3 (2019-03-11)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6
git2r_0.26.1 

@jennybc — just let me know if this is the wrong place, or useless or whatever!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants