#!/bin/sh set -ex USER=u DIR=src/anonymous-ssh HOST=localhost SSH_ID=~/.ssh/id_ed25519 get_sshfp() { ( key="$1" r="${2:-.}" dns=$(mktemp) || exit trap 'rm -rf "$dns"' EXIT ssh-keygen -r "$r" -f "$key" > "$dns" exec < "$dns" while read line do set -- $line if [ "$3 $5" = "SSHFP 2" ] then echo "$line" break fi done ) } make_test_commit() { newfile=newfile.$(date -Ins|tr -d :) touch "$newfile" git add "$newfile" git commit -m "$newfile" } [ -e "$SSH_ID" ] || ssh-keygen -t ed25519 -f "$SSH_ID" -P '' git_namespace=$(set -- $(get_sshfp "$SSH_ID") && echo $6) ssh -o NoHostAuthenticationForLocalhost=yes $USER@$HOST -- test || true [ ! -e anonymous-ssh ] || rm -rf anonymous-ssh export GIT_SSH_COMMAND="ssh -o NoHostAuthenticationForLocalhost=yes -i $SSH_ID" git clone -v ${USER}@${HOST}:${DIR} cd anonymous-ssh make git pull --ff-only make_test_commit git push -f make_test_commit git push git log -n4 git pull --ff-only git log -n4 git push # branch=$(git branch -q --show-current) # forkname=origin-myfork # ns_branch=refs/namespaces/$git_namespace/refs/heads/$branch # git remote add -m "$ns_branch" "$forkname" $(git remote get-url origin) # git push "$forkname" # git pull "$forkname" --ff-only "$branch" exit