Giter Club home page Giter Club logo

soft-serve's Introduction

Soft Serve

A nice rendering of some melting ice cream with the words ‘Charm Soft Serve’ next to it
Latest Release GoDoc Build Status

A tasty, self-hostable Git server for the command line. 🍦

Soft Serve screencast
  • Easy to navigate TUI available over SSH
  • Clone repos over SSH, HTTP, or Git protocol
  • Git LFS support with both HTTP and SSH backends
  • Manage repos with SSH
  • Create repos on demand with SSH or git push
  • Browse repos, files and commits with SSH-accessible UI
  • Print files over SSH with or without syntax highlighting and line numbers
  • Easy access control
    • SSH authentication using public keys
    • Allow/disallow anonymous access
    • Add collaborators with SSH public keys
    • Repos can be public or private
    • User access tokens

Where can I see it?

Just run ssh git.charm.sh for an example. You can also try some of the following commands:

# Jump directly to a repo in the TUI
ssh git.charm.sh -t soft-serve

# Print out a directory tree for a repo
ssh git.charm.sh repo tree soft-serve

# Print a specific file
ssh git.charm.sh repo blob soft-serve cmd/soft/main.go

# Print a file with syntax highlighting and line numbers
ssh git.charm.sh repo blob soft-serve cmd/soft/main.go -c -l

Or you can use Soft Serve to browse local repositories using soft browse [directory] or running soft within a Git repository.

Installation

Soft Serve is a single binary called soft. You can get it from a package manager:

# macOS or Linux
brew tap charmbracelet/tap && brew install charmbracelet/tap/soft-serve

# Windows (with Winget)
winget install charmbracelet.soft-serve

# Arch Linux
pacman -S soft-serve

# Nix
nix-env -iA nixpkgs.soft-serve

# Debian/Ubuntu
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
sudo apt update && sudo apt install soft-serve

# Fedora/RHEL
echo '[charm]
name=Charm
baseurl=https://repo.charm.sh/yum/
enabled=1
gpgcheck=1
gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo
sudo yum install soft-serve

You can also download a binary from the releases page. Packages are available in Alpine, Debian, and RPM formats. Binaries are available for Linux, macOS, and Windows.

Or just install it with go:

go install github.com/charmbracelet/soft-serve/cmd/soft@latest

A Docker image is also available.

Setting up a server

Make sure git is installed, then run soft serve. That’s it.

This will create a data directory that will store all the repos, ssh keys, and database.

To change the default data path use SOFT_SERVE_DATA_PATH environment variable.

SOFT_SERVE_DATA_PATH=/var/lib/soft-serve soft serve

When you run Soft Serve for the first time, make sure you have the SOFT_SERVE_INITIAL_ADMIN_KEYS environment variable is set to your ssh authorized key. Any added key to this variable will be treated as admin with full privileges.

Using this environment variable, Soft Serve will create a new admin user that has full privileges. You can rename and change the user settings later.

Check out Systemd on how to run Soft Serve as a service using Systemd. Soft Serve packages in our Apt/Yum repositories come with Systemd service units.

Server Configuration

Once you start the server for the first time, the settings will be in config.yaml under your data directory. The default config.yaml is self-explanatory and will look like this:

# Soft Serve Server configurations

# The name of the server.
# This is the name that will be displayed in the UI.
name: "Soft Serve"

# Log format to use. Valid values are "json", "logfmt", and "text".
log_format: "text"

# The SSH server configuration.
ssh:
  # The address on which the SSH server will listen.
  listen_addr: ":23231"

  # The public URL of the SSH server.
  # This is the address that will be used to clone repositories.
  public_url: "ssh://localhost:23231"

  # The path to the SSH server's private key.
  key_path: "ssh/soft_serve_host"

  # The path to the SSH server's client private key.
  # This key will be used to authenticate the server to make git requests to
  # ssh remotes.
  client_key_path: "ssh/soft_serve_client"

  # The maximum number of seconds a connection can take.
  # A value of 0 means no timeout.
  max_timeout: 0

  # The number of seconds a connection can be idle before it is closed.
  idle_timeout: 120

# The Git daemon configuration.
git:
  # The address on which the Git daemon will listen.
  listen_addr: ":9418"

  # The maximum number of seconds a connection can take.
  # A value of 0 means no timeout.
  max_timeout: 0

  # The number of seconds a connection can be idle before it is closed.
  idle_timeout: 3

  # The maximum number of concurrent connections.
  max_connections: 32

# The HTTP server configuration.
http:
  # The address on which the HTTP server will listen.
  listen_addr: ":23232"

  # The path to the TLS private key.
  tls_key_path: ""

  # The path to the TLS certificate.
  tls_cert_path: ""

  # The public URL of the HTTP server.
  # This is the address that will be used to clone repositories.
  # Make sure to use https:// if you are using TLS.
  public_url: "http://localhost:23232"

# The database configuration.
db:
  # The database driver to use.
  # Valid values are "sqlite" and "postgres".
  driver: "sqlite"
  # The database data source name.
  # This is driver specific and can be a file path or connection string.
  # Make sure foreign key support is enabled when using SQLite.
  data_source: "soft-serve.db?_pragma=busy_timeout(5000)&_pragma=foreign_keys(1)"

# Git LFS configuration.
lfs:
  # Enable Git LFS.
  enabled: true
  # Enable Git SSH transfer.
  ssh_enabled: false

# Cron job configuration
jobs:
  mirror_pull: "@every 10m"

# The stats server configuration.
stats:
  # The address on which the stats server will listen.
  listen_addr: ":23233"
# Additional admin keys.
#initial_admin_keys:
#  - "ssh-rsa AAAAB3NzaC1yc2..."

You can also use environment variables, to override these settings. All server settings environment variables start with SOFT_SERVE_ followed by the setting name all in uppercase. Here are some examples:

  • SOFT_SERVE_NAME: The name of the server that will appear in the TUI
  • SOFT_SERVE_SSH_LISTEN_ADDR: SSH listen address
  • SOFT_SERVE_SSH_KEY_PATH: SSH host key-pair path
  • SOFT_SERVE_HTTP_LISTEN_ADDR: HTTP listen address
  • SOFT_SERVE_HTTP_PUBLIC_URL: HTTP public URL used for cloning
  • SOFT_SERVE_GIT_MAX_CONNECTIONS: The number of simultaneous connections to git daemon

Database Configuration

Soft Serve supports both SQLite and Postgres for its database. Like all other Soft Serve settings, you can change the database driver and data source using either config.yaml or environment variables. The default config uses SQLite as the default database driver.

To use Postgres as your database, first create a Soft Serve database:

psql -h<hostname> -p<port> -U<user> -c 'CREATE DATABASE soft_serve'

Then set the database data source to point to your Postgres database. For instance, if you're running Postgres locally, using the default user postgres and using a database name soft_serve, you would have this config in your config file or environment variable:

db:
  driver: "postgres"
  data_source: "postgres://postgres@localhost:5432/soft_serve?sslmode=disable"

Environment variables equivalent:

SOFT_SERVE_DB_DRIVER=postgres \
SOFT_SERVE_DB_DATA_SOURCE="postgres://postgres@localhost:5432/soft_serve?sslmode=disable" \
soft serve

You can specify a database connection password in the data source url. For example, postgres://myuser:dbpass@localhost:5432/my_soft_serve_db.

LFS Configuration

Soft Serve supports both Git LFS HTTP and SSH protocols out of the box, there is no need to do any extra set up.

Use the lfs config section to customize your Git LFS server.

Note: The pure-SSH transfer is disabled by default.

Server Access

Soft Serve at its core manages your server authentication and authorization. Authentication verifies the identity of a user, while authorization determines their access rights to a repository.

To manage the server users, access, and repos, you can use the SSH command line interface.

Try ssh localhost -i ~/.ssh/id_ed25519 -p 23231 help for more info. Make sure you use your key here.

For ease of use, instead of specifying the key, port, and hostname every time you SSH into Soft Serve, add your own Soft Serve instance entry to your SSH config. For instance, to use ssh soft instead of typing ssh localhost -i ~/.ssh/id_ed25519 -p 23231, we can define a soft entry in our SSH config file ~/.ssh/config.

Host soft
  HostName localhost
  Port 23231
  IdentityFile ~/.ssh/id_ed25519

Now, we can do ssh soft to SSH into Soft Serve. Since git is also aware of this config, you can use soft as the hostname for your clone commands.

git clone ssh://soft/dotfiles
# make changes
# add & commit
git push origin main

Note The -i part will be omitted in the examples below for brevity. You can add your server settings to your sshconfig for quicker access.

Authentication

Everything that needs authentication is done using SSH. Make sure you have added an entry for your Soft Serve instance in your ~/.ssh/config file.

By default, Soft Serve gives ready-only permission to anonymous connections to any of the above protocols. This is controlled by two settings anon-access and allow-keyless.

  • anon-access: Defines the access level for anonymous users. Available options are no-access, read-only, read-write, and admin-access. Default is read-only.
  • allow-keyless: Whether to allow connections that doesn't use keys to pass. Setting this to false would disable access to SSH keyboard-interactive, HTTP, and Git protocol connections. Default is true.
$ ssh -p 23231 localhost settings
Manage server settings

Usage:
  ssh -p 23231 localhost settings [command]

Available Commands:
  allow-keyless Set or get allow keyless access to repositories
  anon-access   Set or get the default access level for anonymous users

Flags:
  -h, --help   help for settings

Use "ssh -p 23231 localhost settings [command] --help" for more information about a command.

Note These settings can only be changed by admins.

When allow-keyless is disabled, connections that don't use SSH Public Key authentication will get denied. This means cloning repos over HTTP(s) or git:// will get denied.

Meanwhile, anon-access controls the access level granted to connections that use SSH Public Key authentication but are not registered users. The default setting for this is read-only. This will grant anonymous connections that use SSH Public Key authentication read-only access to public repos.

anon-access is also used in combination with allow-keyless to determine the access level for HTTP(s) and git:// clone requests.

SSH

Soft Serve doesn't allow duplicate SSH public keys for users. A public key can be associated with one user only. This makes SSH authentication simple and straight forward, add your public key to your Soft Serve user to be able to access Soft Serve.

HTTP

You can generate user access tokens through the SSH command line interface. Access tokens can have an optional expiration date. Use your access token as the basic auth user to access your Soft Serve repos through HTTP.

# Create a user token
ssh -p 23231 localhost token create 'my new token'
ss_1234abc56789012345678901234de246d798fghi

# Or with an expiry date
ssh -p 23231 localhost token create --expires-in 1y 'my other token'
ss_98fghi1234abc56789012345678901234de246d7

Now you can access to repos that require read-write access.

git clone http://ss_98fghi1234abc56789012345678901234de246d7@localhost:23232/my-private-repo.git my-private-repo
# Make changes and push

Authorization

Soft Serve offers a simple access control. There are four access levels, no-access, read-only, read-write, and admin-access.

admin-access has full control of the server and can make changes to users and repos.

read-write access gets full control of repos.

read-only can read public repos.

no-access denies access to all repos.

User Management

Admins can manage users and their keys using the user command. Once a user is created and has access to the server, they can manage their own keys and settings.

To create a new user simply use user create:

# Create a new user
ssh -p 23231 localhost user create beatrice

# Add user keys
ssh -p 23231 localhost user add-pubkey beatrice ssh-rsa AAAAB3Nz...
ssh -p 23231 localhost user add-pubkey beatrice ssh-ed25519 AAAA...

# Create another user with public key
ssh -p 23231 localhost user create frankie '-k "ssh-ed25519 AAAATzN..."'

# Need help?
ssh -p 23231 localhost user help

Once a user is created, they get read-only access to public repositories. They can also create new repositories on the server.

Users can manage their keys using the pubkey command:

# List user keys
ssh -p 23231 localhost pubkey list

# Add key
ssh -p 23231 localhost pubkey add ssh-ed25519 AAAA...

# Wanna change your username?
ssh -p 23231 localhost set-username yolo

# To display user info
ssh -p 23231 localhost info

Repositories

You can manage repositories using the repo command.

# Run repo help
$ ssh -p 23231 localhost repo help
Manage repositories

Usage:
  ssh -p 23231 localhost repo [command]

Aliases:
  repo, repos, repository, repositories

Available Commands:
  blob         Print out the contents of file at path
  branch       Manage repository branches
  collab       Manage collaborators
  create       Create a new repository
  delete       Delete a repository
  description  Set or get the description for a repository
  hide         Hide or unhide a repository
  import       Import a new repository from remote
  info         Get information about a repository
  is-mirror    Whether a repository is a mirror
  list         List repositories
  private      Set or get a repository private property
  project-name Set or get the project name for a repository
  rename       Rename an existing repository
  tag          Manage repository tags
  tree         Print repository tree at path

Flags:
  -h, --help   help for repo

Use "ssh -p 23231 localhost repo [command] --help" for more information about a command.

To use any of the above repo commands, a user must be a collaborator in the repository. More on this below.

Creating Repositories

To create a repository, first make sure you are a registered user. Use the repo create <repo> command to create a new repository:

# Create a new repository
ssh -p 23231 localhost repo create icecream

# Create a repo with description
ssh -p 23231 localhost repo create icecream '-d "This is an Ice Cream description"'

# ... and project name
ssh -p 23231 localhost repo create icecream '-d "This is an Ice Cream description"' '-n "Ice Cream"'

# I need my repository private!
ssh -p 23231 localhost repo create icecream -p '-d "This is an Ice Cream description"' '-n "Ice Cream"'

# Help?
ssh -p 23231 localhost repo create -h

Or you can add your Soft Serve server as a remote to any existing repo, given you have write access, and push to remote:

git remote add origin ssh://localhost:23231/icecream

After you’ve added the remote just go ahead and push. If the repo doesn’t exist on the server it’ll be created.

git push origin main

Repositories can be nested too:

# Create a new nested repository
ssh -p 23231 localhost repo create charmbracelet/icecream

# Or ...
git remote add charm ssh://localhost:23231/charmbracelet/icecream
git push charm main

Deleting Repositories

You can delete repositories using the repo delete <repo> command.

ssh -p 23231 localhost repo delete icecream

Renaming Repositories

Use the repo rename <old> <new> command to rename existing repositories.

ssh -p 23231 localhost repo rename icecream vanilla

Repository Collaborators

Sometimes you want to restrict write access to certain repositories. This can be achieved by adding a collaborator to your repository.

Use the repo collab <command> <repo> command to manage repo collaborators.

# Add collaborator to soft-serve
ssh -p 23231 localhost repo collab add soft-serve frankie

# Add collaborator with a specific access level
ssh -p 23231 localhost repo collab add soft-serve beatrice read-only

# Remove collaborator
ssh -p 23231 localhost repo collab remove soft-serve beatrice

# List collaborators
ssh -p 23231 localhost repo collab list soft-serve

Repository Metadata

You can also change the repo's description, project name, whether it's private, etc using the repo <command> command.

# Set description for repo
ssh -p 23231 localhost repo description icecream "This is a new description"

# Hide repo from listing
ssh -p 23231 localhost repo hidden icecream true

# List repository info (branches, tags, description, etc)
ssh -p 23231 localhost repo icecream info

To make a repository private, use repo private <repo> [true|false]. Private repos can only be accessed by admins and collaborators.

ssh -p 23231 localhost repo private icecream true

Repository Branches & Tags

Use repo branch and repo tag to list, and delete branches or tags. You can also use repo branch default to set or get the repository default branch.

Repository Tree

To print a file tree for the project, just use the repo tree command along with the repo name as the SSH command to your Soft Serve server:

ssh -p 23231 localhost repo tree soft-serve

You can also specify the sub-path and a specific reference or branch.

ssh -p 23231 localhost repo tree soft-serve server/config
ssh -p 23231 localhost repo tree soft-serve main server/config

From there, you can print individual files using the repo blob command:

ssh -p 23231 localhost repo blob soft-serve cmd/soft/main.go

You can add the -c flag to enable syntax coloring and -l to print line numbers:

ssh -p 23231 localhost repo blob soft-serve cmd/soft/main.go -c -l

Use --raw to print raw file contents. This is useful for dumping binary data.

Repository webhooks

Soft Serve supports repository webhooks using the repo webhook command. You can create and manage webhooks for different repository events such as push, collaborators, and branch_tag_create events.

Manage repository webhooks

Usage:
  ssh -p 23231 localhost repo webhook [command]

Aliases:
  webhook, webhooks

Available Commands:
  create      Create a repository webhook
  delete      Delete a repository webhook
  deliveries  Manage webhook deliveries
  list        List repository webhooks
  update      Update a repository webhook

Flags:
  -h, --help   help for webhook

The Soft Serve TUI

TUI example showing a diff

Soft Serve TUI is mainly used to browse repos over SSH. You can also use it to browse local repositories with soft browse or running soft within a Git repository.

ssh localhost -p 23231

It's also possible to “link” to a specific repo:

ssh -p 23231 localhost -t soft-serve

You can copy text to your clipboard over SSH. For instance, you can press c on the highlighted repo in the menu to copy the clone command 1.

Hooks

Soft Serve supports git server-side hooks pre-receive, update, post-update, and post-receive. This means you can define your own hooks to run on repository push events. Hooks can be defined as a per-repository hook, and/or global hooks that run for all repositories.

You can find per-repository hooks under the repository hooks directory.

Globs hooks can be found in your SOFT_SERVE_DATA_PATH directory under hooks. Defining global hooks is useful if you want to run CI/CD for example.

Here's an example of sending a message after receiving a push event. Create an executable file <data path>/hooks/update:

#!/bin/sh
#
# An example hook script to echo information about the push
# and send it to the client.

refname="$1"
oldrev="$2"
newrev="$3"

# Safety check
if [ -z "$GIT_DIR" ]; then
        echo "Don't run this script from the command line." >&2
        echo " (if you want, you could supply GIT_DIR then run" >&2
        echo "  $0 <ref> <oldrev> <newrev>)" >&2
        exit 1
fi

if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
        echo "usage: $0 <ref> <oldrev> <newrev>" >&2
        exit 1
fi

# Check types
# if $newrev is 0000...0000, it's a commit to delete a ref.
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
if [ "$newrev" = "$zero" ]; then
        newrev_type=delete
else
        newrev_type=$(git cat-file -t $newrev)
fi

echo "Hi from Soft Serve update hook!"
echo
echo "RefName: $refname"
echo "Change Type: $newrev_type"
echo "Old SHA1: $oldrev"
echo "New SHA1: $newrev"

exit 0

Now, you should get a message after pushing changes to any repository.

A note about RSA keys

Unfortunately, due to a shortcoming in Go’s x/crypto/ssh package, Soft Serve does not currently support access via new SSH RSA keys: only the old SHA-1 ones will work.

Until we sort this out you’ll either need an SHA-1 RSA key or a key with another algorithm, e.g. Ed25519. Not sure what type of keys you have? You can check with the following:

$ find ~/.ssh/id_*.pub -exec ssh-keygen -l -f {} \;

If you’re curious about the inner workings of this problem have a look at:

Feedback

We’d love to hear your thoughts on this project. Feel free to drop us a note!

License

MIT


Part of Charm.

The Charm logo

Charm热爱开源 • Charm loves open source

Footnotes

  1. Copying over SSH depends on your terminal support of OSC52. Refer to go-osc52 for more information.

soft-serve's People

Contributors

actions-user avatar aymanbagabas avatar bashbunni avatar caarlos0 avatar camilogarcialarotta avatar dependabot[bot] avatar jolheiser avatar kbdharun avatar levidurfee avatar luandy64 avatar m13t avatar maaslalani avatar meowgorithm avatar muesli avatar penguwin avatar pingiun avatar pratikkuikel avatar snan avatar troylusty avatar wahjava avatar wissam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

soft-serve's Issues

Connection closes immediately when `menu` in the config is empty.

After removing all entries from menu in the config, ssh'ing to Soft-Serve causes the connection to immediately close after disconnecting. Additionally, the cursor visibility is not restored.

{
	"name": "Soft-Serve",
	"show_all_repos": false,
	"host": "localhost",
	"port": 23231,
	"menu": []
}

Typo in the README

There's a small typo in the README, on a link, in the installation section:

You can also download a binary from the [releases][releases] page

I suspect that the reference is either missing or wrong.

First run on Windows fails with mkdir error

I am running Windows 11. After downloading soft-serve_0.1.0_Windows_x86_64.zip and extracting the .exe file, running soft gives:

C:\Users\MyName>soft
2021/12/09 08:21:04 mkdir : The system cannot find the path specified.

This error is repeated for trying soft --help, soft -h, soft /? and any other likely command-line switches for help.

Whereas when I try the .deb package in Ubuntu running in WSL2, I get the expected result:

MyName@MyComputer:~$ soft
2021/12/09 08:29:58 Starting SSH server on :23231

Permission denied accessing config, while documentation states it is open by default.

The documentation states the following:

The config repo is publicly writable by default, so be sure to setup your access as desired. You can also set the SOFT_SERVE_INITIAL_ADMIN_KEY environment variable before first run and it will restrict access to that initial public key until you configure things otherwise.

I can run the server, but when I try to connect, either with ssh localhost -p 23231 or clonning the config repo with git clone ssh://localhost:23231/config, it prompts me for a password, and no matter what I input, it says Permission denied.

I've been able to connect to the server after editing the configuration using a direct folder clone (git clone /home/myuser/.repos/config) and setting allow-keyless to True and restarting the server.

I'm not sure if the solution should be updating the documentation or changing the default behaviour, but in any case something should be changed.

I hope this report helps, thanks for the nice program!

Docs for visible repos in menu possibly misleading

In the configuration file example available in the README, there is a comment above the repo list item that states:

# Which repos should appear in the menu?

However, I have noticed that if I push a new repo to soft without an entry in the repo list configuration it still shows up in the menu, even for non admin users.

In fact, the only way I have found to be possible hide a repo from the menu is with the following steps:

  1. Create an entry for a new repo in the config
  2. Mark the repo's private setting as true
  3. Create a non-admin user which does not have the new repo in its collab-repos
  4. ssh into soft with said user

Therefore, the documentation stating Which repos should appear in the menu? seems misleading, unless I am missing anything. A suggestion for an alternative doc (taking into account I have very little experience with the tool) could be something like:

# Customization of avaialble repos
# If a pushed repo is not included here, then it will be public and visible by default

Some extra details:

  • The version I'm working with is Soft Serve v0.1.3 (3aa9bf3)
  • When reproducing the issue my config for anon-access was no-access, and for allow-keyless was false

Finally, my sincere thanks to the maintainers for this awesome project 😄

debug messages on TUI

Hi, Cool program.

Trying soft on windows (native & docker) & linux. Some challenges, but less than my recent excursion into git-annex. Really need to improve my basic understandings on several fronts, especially with git.

Anyways, I notice the debug statements popping up on my TUI when I scroll.

On the bottom left of the screen I am seeing messages such as, "debug2: channel 0: rcvd adjust 3", etc..

I am just wondering if I've botched my build somehow.? I believe this was on a go install built version. As I don't really know go, and struggled building it, perhaps it's related to that.
soft -version Soft Serve (built from source)
I think I ended up there, as brew wouldn't install on my vps. And the direct install didn't install, or work as expected.

The 'ssh git.charm.sh' version has no issues for me.

Config Private Value not honored by TUI menu

Hello,

First off I love this project. Just starting to use it and plan on moving all my personal Git repos to it. One thing I'm running into during my initial test setup is that the Private config option does not seem to be honored. I have this in my config

repos:
   - name: Welcome
     repo: Welcome
     private: false
     note: "Welcome Page"
   - name: Settings
     repo: config
     private: true
     note: "Configuration and content repo for this server"

but when I connect without Auth the Settings repo still shows up in the menu. Am I misunderstanding something? Sorry if I missed something obvious. I'm just connecting locally for now.

Soft Serve does not support custom terminfo files (such as kitty)

The Problem

When attempting to connect to a TUI that runs Soft Serve (such as git.charm.sh, or localhost:23231 when running soft locally, the SSH session immediately exists after initially connecting.

Looking at the logs for the soft program, it appears to output a shell script that should run on the client. Looking at the verbose logs for SSH, the shell script is only partially received and the SSH connection then closes. (Notably, the SSH connection exits without producing an error.)

Working with git on the server works as expected. git clone ssh://localhost:23231/config succeeded, and I was able to edit and push a new configuration up with no issues.

Host Information

OS: NixOS 22.05 (Unstable)
Kernel: Linux 5.16.2
Shell: ZSH 5.8
SSH Version: OpenSSH 8.8p1
Terminal: kitty
$TERM: xterm-kitty

Screenshots & Logs

Attempting to connect (-S none to disable multiplexed connection):
image

SSH log (with -v):
http://ix.io/3Nu2

Soft log:
http://ix.io/3Nu3

Modifying syntax Highlighting inside the TUI

I was wondering whether it was possible to modify the TUI's default syntax highlighting? When browsing .vue files for example, the highlighter kinda breaks, presumably because it's trying to read it as a regular HTML file (Notice the wall of orange after it encounters the v-if)

image

I'm using batcat locally which I've configured specifically with some Vue syntax highlighting rules, so was wondering if it was possible to force soft-serve to use that instead the TUI?

browsing the repository files

when selecting a repository the readme is displayed, but it is not possible to browse (view) the repository files

repository does not exist when SOFT_SERVE_REPO_PATH is used on a mounted drive

I am running Soft Serve built from source on a Raspberry Pi. I am attempting to set SOFT_SERVE_REPO_PATH to a difderent folder which is a mounted USB drive. When I run soft, I get an error: repository does not exist. It appears to still work when run on a regular folder. Also, the user I'm running soft from has access to the mounted folder.

Allow for groups of repos

Basically: directories. Grouping repos into directories helps in organisation. Example repos:

ssh://git.example.soft/bla1
ssh://git.example.soft/group1/bla2
ssh://git.example.soft/group1/bla3
ssh://git.example.soft/group1/subgroup1/bla4
ssh://git.example.soft/group1/subgroup1/bla5

Tree error after switching refs

When browsing files, switching refs, and then returning to the tree, if the last file or directory browsed doesn't exist in the current ref a error is displayed and it's impossible to further navigate the tree.

The solution here is probably to reset the state of the tree after changing refs.

Option to change an existing repo's default branch

First off, thank you so much for your work on this open source project!

Currently the only way to change the default branch is to ssh directly into the Soft Serve host and manually reassign the HEAD symref via git symbolic-ref HEAD refs/heads/main. This isn't a setting that can be set on the client-side and pushed, it must be set server-side. Other git servers like (GitHub, GitLab, Gitea, etc) usually offer a "settings" option in the UI to change this. This is necessary when moving old or misconfigured repos from master to main, for example.

It would be spiffy if there were a way to change this setting from the TUI, and might fold in nicely with other server-side settings like CI/CD features (#49) in the future.

Doesn't seem to work correctly on Windows...

If I run this on Windows, (installing via go install as shown in the README) then using the Windows command line git client fails with an unexpected protocol error.

git clone ssh://localhost:23231/config
Cloning into 'config'...
fatal: protocol error: unexpected 'something went wrong'

Hosting soft-serve on Windows and accessing the TUI works fine for both Linux and Windows SSH clients.

Hosting soft-serve on Windows and cloning using git clients on both Linux and Windows fails with the above error.

Hosting soft-serve on Linux and using the TUI from Windows SSH and git clients works fine.

Hosting soft-serve on Linux and using the SSH protocol to clone on Windows and Linux both work fine.

I can't imagine that this will be a high priority, but I felt it worthy of an issue, because it is an issue. I don't know if it's soft-serve's issue, but it is an issue.

Access Soft Serve On Remote Server

Hi there,

I installed Soft Serve on a remote server. It works great in local, but I have trouble accessing it from the outside.

I would like to setup something like your git.charm.sh to access it from my local computer. But so far I failed.

Could you share the parts of your Nginx config that makes ssh git.charm.sh possible?

Thank you very much!

connected refused when running soft-serve as a container

Description

I try to use docker to run soft-serve. The container create successfully, and I am sure environment variables are set correctly.
Then I try to connect to the TUI via ssh, something very bad happened.

What I expect to see

TUI views.

What actually happened

Connection refused.

image

My config

OS

Ubuntu 20.04 LTS.

OS environment variables

image

docker-compose.yml

---
version: "3.1"
services:
  soft-serve:
    image: charmcli/soft-serve:latest
    container_name: soft-serve
    volumes:
      - ~/soft-serve/data:/soft-serve
    ports:
      - 27017:23231
    restart: unless-stopped
    environment:
      - SOFT_SERVE_INITIAL_ADMIN_KEY=<My public key>

Others

btw, Charm is so cooooooool!

Beginner issue: what is the format for the authorized user keys in config.yaml?

Hello! I know this is a beginner's issue, but I've been pulling my hair out over trying to get user keys working.

The example lists this format for creating authorized users:

users:
  - name: Beatrice
    admin: true
    public-keys:
      - KEY TEXT

To me, KEY TEXT was vague, and ended up trying the following options without success:

  1. copy and pasted the full public SSH key (in rsa format)
  2. name of the public SSH key file in .ssh
  3. full path to the public ssh key file in .ssh

Every time I got the error bad yaml in config.yaml: yaml: line 25: did not find expected key

I know I'm missing something obvious, is there a specific file that the ssh key needs to be stored in first? Is the format incorrect? Any help would be great.

I'm running soft on a debian server, and I installed using homebrew.

systemd ignoring SOFT_SERVE_HOST but all env vars respected when binary launched with `soft`

Issue: The SOFT_SERVE_HOST environment variable is not being respected when soft is launched with systemd, causing the git clone address to read localhost instead of SOFT_SERVE_HOST in the TUI. However, when running soft with the service disabled in systemctl and all the same environment variables set, the git clone address will show the correct SOFT_SERVE_HOST value.

Steps to reproduce (this was done on a fresh VM running Debian 11):

  1. Set environment variables in /etc/environment:
SOFT_SERVE_PORT="23231"
SOFT_SERVE_BIND_ADDRESS="0.0.0.0"
SOFT_SERVE_KEY_PATH="/home/ops/.ssh/soft_serve_server_ed25519"
SOFT_SERVE_REPO_PATH="/home/ops/.repos"
SOFT_SERVE_INITIAL_ADMIN_KEY="/home/ops/.ssh/id_ed25519.pub"
SOFT_SERVE_HOST="vcs.hazyville.net"
  1. install git, soft serve
  2. launch with soft and ssh to the TUI

Note the git clone address correctly reflects the SOFT_SERVE_HOST.

  1. create unit file at /etc/systemd/system/soft.service, enable correct perms, with the following content:
[Unit]
Description=hazyville.net softserve instance
After=network.target

[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/usr/bin/soft soft


[Install]
WantedBy=multi-user.target
  1. enable soft.service in systemctl and restart the host

  2. ssh into soft TUI and note the git clone address is now using localhost

  3. Stuff I tried that didn't work:

  • added this line in the [Service] stanza:
PassEnvironment=SOFT_SERVE_HOST
  • added the env vars into the user ~/.profile as exports
  • adding a wait timer to the service to ensure all vars loaded before service
  • ssh from directly on the soft host and from remotes (all had same issue if soft had been launched with systemd)
  1. Disabling the service in systemctl and relaunching with soft with no changes to the env vars will result in correct SOFT_SERVE_HOST in the TUI.

CI/CD features

Hello,
I like the idea of the project. Do you think it would be a good idea to add CI/CD features ?

Something like github actions living in .soft/workflows or maybe supporting the format of gitlab-ci.yml - one could reuse the gitlab workers, since they are a standalone project.

Cheers

Feature Request: Webhook Support

By implementing webhook support in soft-serve users could integrate with any CICD system that supports webhooks. I'm not sure how to go about implementing this since soft-serve is SSH based but would be happy to lend a hand.

Unable to login with my rsa key

I configured my soft-serve server to only accept public key authentication. I am currently on the commit e8b5146.

For some strange reason, on one of my computer, the RSA key is not accepted by the server. When I run ssh -v I got the following output:

debug1: Authentications that can continue: publickey                                           
debug1: Next authentication method: publickey                                                  
debug1: Offering public key: /home/maki/.ssh/id_rsa RSA SHA256:uv+MKsX3MQHgDO5rlO0JenaP0oZbK87vcx+4BnOfr+4                                                                                     
debug1: send_pubkey_test: no mutual signature algorithm

On one of my other computer, the RSA key is accepted with no trouble:

debug1: Offering public key: /root/.ssh/id_rsa RSA SHA256:7F/em69/OfQsroSBri2JjxoCjsLB2qsVGGCA998vdUo                                                                                          
debug1: Server accepts key: /root/.ssh/id_rsa RSA SHA256:7F/em69/OfQsroSBri2JjxoCjsLB2qsVGGCA998vdUo                                                                                           
debug1: Authentication succeeded (publickey).

This is not a very problematic issue as I could solve it by using an ed25519 key instead of the ssh one but this is still very intriguing.

I do not know if that matter but the computer with the faulty behavior is running openSUSE Tumbleweed.

git blame functionality

Would it be possible to be able to toggle git-blame annotations to each line when viewing the file in the Files tab of a repo?

Feature Request: Search

Hey there,
first of all I want to say that I'm really impressed by you've done so far and I really want this to become production ready one day.
However I got a question for you: Given that I would want to migrate my repos over to soft-serve, is there a way to search them?

Can't start soft-serve with .ssh in repo

Reproduce:

  1. Create a new folder: mkdir /srv/repo
  2. Go to that folder: cd /srv/repo
  3. Run soft: SOFT_SERVE_REPO_PATH=/srv/repo soft

Soft serve will hang and not start, since .ssh will be at repo path and that confuses soft.

Brew install on Apple Silicon Macintosh referencing non-existant soft-serve

Tried to install using the suggested command from the ReadMe.md file:

% brew tap charmbracelet/tap && brew install charmbracelet/tap/soft-serve
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 4 taps (hashicorp/tap, homebrew/core, homebrew/cask and acorn-io/cli).
==> New Formulae
cargo-crev     enex2notion    gcc@11         gcem           git-sync       [email protected]        lucky-commit   pymupdf        svt-av1
==> New Casks
gittyup                                       imhex                                         yubihsm2-sdk

You have 20 outdated formulae and 1 outdated cask installed.
You can upgrade them with brew upgrade
or list them with brew outdated.

==> Tapping charmbracelet/tap
Cloning into '/opt/homebrew/Library/Taps/charmbracelet/homebrew-tap'...
remote: Enumerating objects: 261, done.
remote: Counting objects: 100% (258/258), done.
remote: Compressing objects: 100% (147/147), done.
remote: Total 261 (delta 140), reused 197 (delta 101), pack-reused 3
Receiving objects: 100% (261/261), 47.67 KiB | 1.08 MiB/s, done.
Resolving deltas: 100% (140/140), done.
Tapped 8 formulae (19 files, 77.4KB).
==> Downloading https://github.com/charmbracelet/soft-serve/releases/download/v0.4.0/soft-serve_0.4.0_Darwin_arm64.tar.gz
==> Downloading from https://objects.githubusercontent.com/github-production-release-asset-2e65be/391209033/aaaec6e3-7abb-49bb-ab19-ea2f3
######################################################################## 100.0%
==> Installing soft-serve from charmbracelet/tap
Error: An exception occurred within a child process:
  Errno::ENOENT: No such file or directory - soft-serve
% 

I was able to get it to install by running:

% brew edit charmbracelet/tap/soft-serve

and changing the install command to only reference soft instead of soft-serve

Charm Theme

Is there a Charm theme for our terminals? I love the design.

Move `repos` config into repos

I'd like to suggest removing the repos configuration from the main config and instead allow for a .softserve.toml file within individual repos for setting the repo config values. In addition, it might make sense to allow including a dedicated users config there, so that users could be configured per-repo.

The reason for this is a separation of service config vs. content config. I find it cumbersome to update the main config every time a new repo is added/an old repo is removed/a repo was changed (e.g. private -> public or added a user).

Soft serve bummer missing repo

when running:

ssh git.local -p 23231

I get "Bummer missing repo" and I can't seem to figure out why. Does anybody know why this is happening?
My config:

# The name of the server to show in the TUI.
name: Soft Serve

# The host and port to display in the TUI. You may want to change this if your
# server is accessible from a different host and/or port that what it's
# actually listening on (for example, if it's behind a reverse proxy).
host: git.local
port: 23231

# Access level for anonymous users. Options are: read-write, read-only and
# no-access.
anon-access: read-write

# You can grant read-only access to users without private keys. Any password
# will be accepted.
allow-keyless: false

# Customize repo display in the menu. Only repos in this list will appear in
# the TUI.
repos:
  - name: Home
    repo: config
    private: true
    note: "Configuration and content repo for this server"

users:
   - name: Admin
     admin: true
     public-keys:
       - [REDACTED]
#   - name: Example User
#     collab-repos:
#       - REPO
#     public-keys:
#       - ssh-ed25519 AAAA... # redacted
#       - ssh-rsa AAAAB3Nz... # redacted

README path is hard coded

First off I just wanted to say this is nice little project that fills the need of wanting to self host some private git repos and not needing a full blown web app like gitea.

Looking at loadRepo the README path is hard coded. I'd like to be able to customize this because I make use of github's alternative path /docs/readme.md.

Failing to create new repo

I followed the instructions on how to create a repo. After push I get the following error message

error: failed to push some refs to 'ssh://git:23231/test'

After push I can find the repo in the .repos

But if I ssh into the TUI I cannot see it. If I later try to reload I get the error Error: reference does not exist

I tried this on a ubuntu 20.04 host installed with apt.

Add support for Git LFS

The Git Large File Storage Extension doesn't currently work with Soft Serve, but it should. Current errors include:

$ git push origin main 
Remote "origin" does not support the LFS locking API. Consider disabling it with:
  $ git config lfs.https://localhost/x-wombat/info/lfs.locksverify false
batch request: unexpected end of JSON inputB/s

and after disabling the lock:

$ git config lfs.https://localhost/x-wombat.git/info/lfs.locksverify false
$ git push origin main 
Uploading LFS objects:   0% (0/1), 0 B | 0 B/s, done.                                                                                                                   
batch request: unexpected end of JSON input
error: failed to push some refs to 'ssh://localhost:23231/x-wombat'

Feature Request: Back

While navigating the tui, it would be handy to be able to use backspace (and right click on mouse) to go back to the previous view.

GPG for the ssh key | Can not clone config

Is it possible to use gpg or like a yubikey for the ssh key instead of creating one local?

I tried but nothing worked and can not clone the config.

I set SOFT_SERVE_INITIAL_ADMIN_KEY to my ssh key with $(ssh-add -L)

Implement syscall.Setgid/syscall.Setuid

One thing that has stopped me from running soft-serve is the fact that it doesn't support binding to port 22 and then dropping the root privileges required to do so, from what I found. Please correct me if I might have overlooked something in the documentation.

It would be nice if there was a way to make soft-serve start as root, open the port and then drop to a different user (e.g. git) in order to run the actual service.

Add support to mirror upstream repositories

Mirroring upstream or external repositories is supported by platforms like gitlab/github/bitbucket.
Something like this comes to mind:

repo:  
  - name: Kubernetes
      repo: kubernetes
      private: false
      note: "A mirror of the upstream kubernetes repository"
      mirror: https://github.com/kubernetes/kubernetes

Softserve could run on a cron and pull upstream code into the repository.

Main branch hijacked when it's not called `master`

When I create a new Git repo locally where the main branch is called something other than master (i.e. main) and push it to a Soft-Serve instance an empty branch called master is created and set as the main branch.

reference not found when running soft

I think I accidentally screwed up my config file and now I get:

reference not found

when running soft
Does anybody know where the config file is stored locally on the server so I can delete it and start again?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.