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

SSH generation question #155

Open
cdwainscott opened this issue Mar 16, 2014 · 10 comments
Open

SSH generation question #155

cdwainscott opened this issue Mar 16, 2014 · 10 comments

Comments

@cdwainscott
Copy link

During our testing we kept running into the issue of whenever we generate a SSH key. If the directory the key will be held in is already created the mkdir() throws and error that the directory already exists. I wasn't sure if we will generate an SSH key for a user more than once. If we only do it once there is no problem but if they have to generate if more than once we need to check if the file or directory is there before we try and make it.

@wwforg
Copy link
Member

wwforg commented Mar 16, 2014

For this I was originally going to set up a check to only generate the key if they do not exist in our database (so the first time that they login) but I am thinking that it would be best to check and see if the file actually exists instead, just in case the user deletes the key from their account. This brings up another question though, if the user deletes the key on the account, to my understanding it will do nothing with the private key on the file system. I can do a test to see if the public key exists on the account, and then see if there is a private key within the file system (since we should only ever have one). If its not on the account but is in the file system we could delete it from the file system and then do the whole process over again. Does that sound workable @ZAM- or @apotheos? If so, would you (@ZAM-) be able to add check and delete methods for the private key?

@mikeholler
Copy link

Sounds workable, I wonder if we'll have enough time to include this before our first release. I say create your pull request assuming the user will never delete the key from their account, and if @ZAM- has time to come through with the other two methods you need, then create another pull request that implements the workflow you described earlier. In other words, we do it in parts. Does that sound fair?

@wwforg
Copy link
Member

wwforg commented Mar 16, 2014

Certainly sounds fair. For the time being I will do the check based on whether or not their in the database. On that note, thus far I have only used the database locally to test queries and such. for using database functions on the server, is there any setup or files that I need to run before the database will be accessible?

@mikeholler
Copy link

Run sudo -u www-data php artisan migrate after every sudo -u www-data git pull and you should be good as far as the server is concerned.

@wwforg
Copy link
Member

wwforg commented Mar 16, 2014

awesome thanks

@ZAM-
Copy link
Contributor

ZAM- commented Mar 17, 2014

@wwforg This does sound workable, but I'll be honest with you, since this is close to the end I don't think I'll have enough time to implement these functions. I have other finals to study for.

I have a question though, how do we check if the user has deleted the key from GH? There might be some information we grab from the token, but I am not sure.

@wwforg
Copy link
Member

wwforg commented Mar 17, 2014

Its possible to grab a list of public keys, so we just loop through those and check if our public key is there. I don't know if that's the most efficient way but its definitely possible.

@mikeholler
Copy link

You would literally have to check the contents of each key @wwforg. It doesn't really matter that it's not efficient because even a power user will probably not have more than a handful of keys, and each key is only about 2024 characters long.

@mikeholler
Copy link

Thanks for responding honestly @ZAM-, I figured that might be the case.

@mikeholler
Copy link

Also, GitHub users rarely if ever need to delete keys, so it would be very rare for this particular problem to arise. Still could happen though.

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

4 participants