Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating Remote GIT server on OSX Client ( Snow Leopard ) to sync with XCode 4 local GIT Repo
    primarykey
    data
    text
    <p><strong>For those who want to create their own git repository on a remote OSX Snow Leopard client box, then sync with it over SSH from XCode 4.1 - read on.</strong> </p> <p>I've managed to get this to work, but I think it might be helpful to others who are now pulling their hair out in the same boat I was in, to read over the steps I took, and for anybody with more experience than myself to point out where I could do things better ( and perhaps include any helpful screen shots etc ).</p> <p>I've just successfully created a working remote git repository on a spare Snow Leopard MacMini, and tested syncing it with XCode 4.1, with a local git repo ( the default local repo for XCode ); unfortunately, it turns out there's a LOT that you have to get right in order for this to work: <em>but it does work!</em> </p> <p><strong>Preliminary:</strong> To avoid confusion for those new to git, ( as far as I'm aware ) GIT is GIT ... that means, there really isn't a special server version and a client version ... for the most part, the GIT that was installed locally on your machine when you installed XCode, is pretty much the same that runs on a "server". The only significant difference is the support software / infrastructure that runs on top. </p> <p>It's this optional separate layer that a server could use to allow users to connect to the underlying git system, that makes most of the difference between a git server ( aka "remote" ) and a git "client". Do folks connect using a web interface running in Apache? Are they running using another kind of user interface mediator ( ie Gitolite ), or are they simply connecting to git directly over SSH, using actual OSX user accounts on the remote server? That's an important one to get your head around if you're new to git and trying to set up your own remote server: <em>direct or mediated access.</em> </p> <p>This note assumes you're only working with a small number of known users, and therefore have no need of an extra mediating layer, and therefore, we'll opt for direct access over SSH using actual OSX accounts. Please also note - this is NOT about sync-ing to GitHub, there's plenty of notes available on that topic elsewhere.</p> <p>But before we go any further, <em>are you sure you just want to use OSX Client accouts rather than a separate user mediating layer?</em> ( like Gitolite / Gitosis etc ) ... keep in mind, that for direct access, every user who'll need to gain access to the server in the future, <em>will require you create an actual OSX client account in System Prefs</em> ... if this isn't much of a hassle, great, otherwise check out Gitolite as it avoids this problem in the long run ( but adds an extra layer of setup in the short term -> <a href="https://github.com/sitaramc/gitolite/" rel="nofollow noreferrer">https://github.com/sitaramc/gitolite/</a> ).</p> <p><strong>SECTION 1</strong> - Setting up your OSX Client GIT server.</p> <p>I'm assuming you DON'T have XCode installed on your OSX git remote box, so you'll have to download and install GIT, fortunately, this part's easy ...</p> <p>From the actual remote box, surf to <a href="http://git-scm.com/" rel="nofollow noreferrer">http://git-scm.com/</a> and get git, open the disk image, then run the installer.</p> <p>Don't forget to also run the "setup git path for non-terminal programs.sh" shell script that comes with the installer ( it's probably right next to the installer on the disk image ) ... sadly it's not the all-round magic link fixer if you're doing what we are, but it does take care of some headaches for the account that did the install.</p> <p><strong>CREATE USER ACCOUNTS:</strong> Since we're NOT using an access mediating layer, you'll create user accounts directly in System Preferences on the remote OSX box for all the users who will be using this service.</p> <p>Create an OSX user Group that will have access to the repository(s), and add these users to that group.</p> <p>In the remote box's System Preferences -> Sharing , enable "Remote Login" ( this <em>is</em> SSH ), you also have the option of only allowing specific users access ... ( more on this service later - as it has to change too )</p> <p>Test the remote login from your local machine, using a personal account you setup earlier:</p> <p>ssh yourname@remoteGitBox.com</p> <p>If you get in, or if you're prompted to create an rsa key, this means you've connected, great - but only create keys for accounts you plan to personally use.</p> <p>If the machine is behind a firewall, port 22 may NOT be open (for good reason!) you'll have to somehow get access to the machine over either this port, or one you select below ... if you're not in control of your firewall, this might be pain - regardless, more on this port stuff below.</p> <p>On the remote machine, create a shared master repository directory in /Users/Shared, something like /Users/Shared/git ... probably best not to get too creative with the naming.</p> <p>For now, create a sub folder in that directory, call it /Users/Shared/git/Test1 or whatever name you like. </p> <p>In the terminal on the remote machine, go to that directory you just made ( /Users/Shared/git/Test1 ) and create the first remote GIT repository, you do this by tying "git --bare init" at the prompt, <em>from inside that directory</em>, this creates all the necessary repo files. There are notes on the meaning of this prompt ... but for now, we just want to get you connected &amp; running, though obviously you should take the time to learn about these prompts at some point. </p> <p>In the Finder GUI on the remote box ( it's generally easier in the GUI on OSX as the perms can get whacky compared to standard UNIX ) select the /Users/Shared/git folder, get info on it, and grant read / write access to that directory and all sub dirs, to the respository access group you created earlier in OSX system preferences. A quick way to apply the changes recursively to all sub-folders, is to unlock the info panel, and click on the little gear symbol at the bottom - select "Apply Changes to Enclosed Items ... "</p> <p><strong>BIG SECURITY ALERT:</strong> As hinted above, unless you want every bot on the internet trying to brute force its way into your repository, you MUST change the remote server's SSH port from 22 to just about anything else ... honest, there's bots all over the net that do nothing but sniff for open port 22s. Changing the port # is hardly the bee's knee's for security - BUT - it will save a LOT of firewall log thrashing, since otherwise, every bot will almost instantly find you and begin brute force attacks.</p> <p><strong>Changing SSH port on the remote OSX git box:</strong></p> <p>On your firewall open a pinhole to some TCP number you're comfy with - for a list of available TCP ports, go here, and pick something <strong>not</strong> on the list: <a href="http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers</a></p> <p>To change the SSH port, you'll have to open /System/Library/LaunchDeamons/ssh.plist but first, MAKE A BACKUP COPY OF THIS FILE!!!! Then open this up in your favorite text editor. ( this requires admin permission to edit ); you'll have to add a "listener" to the list ... here's what I did, and after much pain and suffering, it worked:</p> <p><img src="https://i.stack.imgur.com/NiQr1.png" alt=" /System/Library/LaunchDeamons/ssh.plist changes "></p> <p>Unfortunately, restaring SSH on OSX client with key commands is a science project, so you'll have to go back to system prefs -> sharing, and turn off and then turn on "remote login", or simply restart the box - don't worry, if you did it right, you'll have the standard SSH port open to anybody behind the firewall, and a new port you can ssh in on, which the firewall will point anybody external to.</p> <p>To test the new port, type this on your local machine ssh -p 65534 you@remoteGitBox.com as I'm sure you've guessed, 65534 is the stand in for whatever port number you chose.</p> <p>Once again, create any necessary ssh keys if you're prompted to do so - but only for your account! If you can't log in with SSH over the new port, did you remember to restart the service or the machine? You MUST get this working before anything else will work!</p> <p>Next, you'll have to deal with getting all the necessary path Alias' right on the remote box - if you don't, you'll get the mysterious "git-upload-pack" missing message when you try to push onto the remote repository in XCode.</p> <p>In the terminal, as an admin on the remote box, change directories to /usr/bin/</p> <p>Then in the terminal, type the following command sudo ln -s /usr/local/git/bin/git* . ( yes that's a period, include it ), that path will work if you used the default git installer, if not, you'll have to type sudo ln -s / [path/to/git] /bin/git* . this will require admin access. ( you'll be prompted for a password )</p> <p><strong>So - here's what you've done so far:</strong></p> <ul> <li>Installed git</li> <li>Set up a repository</li> <li>Set up the necessary paths to that repository, including some custom links</li> <li>Created user accounts </li> <li>Created a group for those accounts, and granted that group file level read / write permission to the repository</li> <li>Created a new port to SSH in on</li> <li>Altered your firewall to point to this port ( unless you're crazy, never open port 22 to the internet )</li> </ul> <p><strong>OK, now onto XCode on the local machine</strong></p> <p>I'd recommend creating a new test project ... it doesn't really matter much what you call it, TestProject1 ... but as you step through the template to make it, be certain to create it's own local git repository ( this is an option during the creation template, in the dialogue box ). ( Much of this is covered elsewhere on SO, but to keep with the references you're already used to, I'll continue )</p> <p><em>Now we have to tell XCode on your local machine about the remote repo, and get it sync'd up.</em></p> <p>In XCode on your local machine, go to Window-> Organizer</p> <p>Scroll down the list on the left hand side, and find the new project you've just created.</p> <p>Click on the folder called "remotes"</p> <p>This will open the remote page in the right panel, at the bottom of the page, click the button "add remote"</p> <p>This will open a dialgue box, in the name area, type something for your reference ... this is NOT a URL, so it can short, but somewhat descriptive: like "MacMini_Test1"</p> <p>In the location field, things aren't so simple ... you'll need to type a correct URL to the remote box we just set up ... this can be a pain, but if you did it right, you'll type something like this</p> <p>ssh://you@remoteGitBox.com:65534/Users/Shared/git/test1 </p> <p>and this should work! Please notice how we're including the port number after the address, followed by the absolute path to the repo</p> <p>Click the "create" button, and a new prompt will open, asking for your SSH password ... type it in.</p> <p>Sometimes XCode kinda gets stuck here and you have to restart ... unfortunately, sometimes, you get the URL wrong and it looks exactly the same ... regardless, if you did everything right above ... at least after a restart, things should be ok</p> <p>Get out of the Organizer, and go back to the main XCode window ...</p> <p>Write any small comment into a code file, save it, just to change it ...</p> <p>Commit any changes to the local repository as you normally do ( an M will appear beside the file name in the files list after you save it with your new comment, control click on the file and follow the menu to commit the change to the local repo ): <em>you must commit any local changes before you can "push" these changes to the remote repository.</em> </p> <p><strong>Pushing to the Remote Repo</strong></p> <p>Go to the file menu, select File -> Source Control -> Push</p> <p>A menu should drop down, and after a second or so of checking, <em>a green light should appear, with text next to it saying "Respository is online"</em>, with the name of the Respository in a drop down list, "MacMini_Test1" if you went with the name above.</p> <p>Select the "Push" button ... your changes should get pushed to the remote repo.</p> <p><strong>You're Sooooooooooooo Done!</strong></p> <p>I apologize for not having time to get more graphical with this "how-to", and so many other folks on this system have provided the key information to get this going, it's difficult to start listing ( in short, my apologies - for now, I'll add more kudos as time goes by ). Regardless ... that, is what you need to do to get a personal git remote server running, on OSX Snow Leopard, behind a firewall, on a customized SSH port, to link up with a project in XCode 4.1 or greater.</p> <p><strong>Whew!</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload