CSC495-2014 / TeamworkEnglewoodGit

GNU General Public License v2.0
5 stars 15 forks source link

SSH generation question #155

Open cdwainscott opened 10 years ago

cdwainscott commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

awesome thanks

ZAM- commented 10 years ago

@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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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

mikeholler commented 10 years ago

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.