User Tools

Site Tools


access_sdf_gitea_using_ssh_keys

Futurile spent some time investigating and eventually got to the bottom of it.

Useful information is that the Gitea server (git.sdf.org) is hosted on ma.sdf.org. After your Gitea account is created, it will reside on ma.sdf.org at /meta/gitea/gitea-repositories/<your userid>/<git-repository-name>.git.

  1. Create Gitea account as instructed in Hosted git repos.
  2. Login to the Gitea webapp and navigate to the repository for which you want SSH key access. (Create a new repository if needed.)
  3. Upload a public ssh key using the Gitea webapp.
    • In then Gitea web app go to Settings (top right) and then SSH/GPG Keys. In the Manage SSH Keys select 'Add Key' and upload a public SSH key.
    • Gitea manages the public SSH key *separately* from any other that you use to normally access ma.sdf.org. Some people are using:
      • their existing ma.sdf.org public ssh key and they're uploading it to gitea
      • a new key pair specifically for this gitea. Either of these is fine.
  4. Check that public key authentication to Gitea is working.
    • The Gitea server is running on the system as the 'git' user, so you need to ssh into it using 'git' as the username (rather than your normal sdf username).
    • The Gitea server is running on port 2222, so our test of public key authentication will specify this port manually. (It is possible for the server to switch seamlessly to port 2222 whenever the 'git' username attempts an SSH connection, but this option has not been configured at present.)
    • At the command line, test that your newly-uploaded SSH key is recognized by Gitea. A dedicated stanza for git.sdf.org in $HOME/.ssh/config will load the key automatically, or you can use ssh-agent as shown below.
      $ keychain ~/.ssh/<the-ssh-key-in-gitea>
      $ ssh -vvv git@git.sdf.org -p 2222
    • You'll see a load of output, if it's successful you'll see:
      Offering public key: <key> 
      <more output>
      debug1: Authentication succeeded (publickey).
      Authenticated to git.sdf.org ([205.166.94.33]:2222).

      The server is not configured to allow shell access over this SSH connection, so the test will terminate automatically and return you to your local machine.

  5. Set up your repository one of two ways:
    1. Use the repository via git
      • The Gitea web page for any empty repository you create will show you the commands for accessing it via ssh. (Once content is uploaded, this information disappears from the landing page of the repository.) Because Gitea is actually running on port 2222, you have to add this to the command line provided.
        $ git pull git@git.sdf.org:2222/<your-sdf-id>/<repository-name>.git
        $ git pull git@git.sdf.org:2222/futurile/futurile-www.git

        or instead

    2. Import an existing repository
      • I had an existing repository that I wanted to now upload into gitea. To do that we add a new remote.
        $ git remote add <name> <url>
        $ git remote add upstream ssh://git@sdf.org:2222/futurile/futurile-www.git
        $ git push upstream master
      • For my own reasons I've called the remote 'master' whereas most instructions call it 'origin' - but it's the same thing.
  6. Check output in Gitea
    • You should see output on the command-line, and when you login to the Gitea web app you can verify that the files were uploaded.
access_sdf_gitea_using_ssh_keys.txt · Last modified: 2022/02/07 21:37 by jquah