OpenSSH config in XDG directory

Here is a an example session of patching application to store user data in XDG directory. Not implementation of XDG Base Directory Specification. Just a workaround for those who do not like configuration files in $HOME.

Receive source:

$ yay -G openssh
$ makepkg -o
    openssh-8.3p1.tar.gz ... FAILED (unknown public key D3E5F56B6D920D30)
==> ERROR: One or more PGP signatures could not be verified!
$ gpg --recv-key D3E5F56B6D920D30
$ gpg --lsign D3E5F56B6D920D30
$ makepkg -o
$ cd src/openssh-8.3p1

Config stored in "~/.ssh" by default, search for it:

$ grep '\.ssh' *.h *.c
pathnames.h:60:#define _PATH_SSH_USER_DIR         ".ssh"

Looks like what we need, check usage:

$ grep -rn _PATH_SSH_USER_DIR .
./pathnames.h:60:#define _PATH_SSH_USER_DIR              ".ssh"
./pathnames.h:67:#define _PATH_SSH_USER_HOSTFILE         "~/" _PATH_SSH_USER_DIR "/known_hosts"
./pathnames.h:69:#define _PATH_SSH_USER_HOSTFILE2        "~/" _PATH_SSH_USER_DIR "/known_hosts2"
./pathnames.h:75:#define _PATH_SSH_CLIENT_ID_DSA         _PATH_SSH_USER_DIR "/id_dsa"
./pathnames.h:76:#define _PATH_SSH_CLIENT_ID_ECDSA       _PATH_SSH_USER_DIR "/id_ecdsa"
./pathnames.h:77:#define _PATH_SSH_CLIENT_ID_RSA         _PATH_SSH_USER_DIR "/id_rsa"
./pathnames.h:78:#define _PATH_SSH_CLIENT_ID_ED25519     _PATH_SSH_USER_DIR "/id_ed25519"
./pathnames.h:79:#define _PATH_SSH_CLIENT_ID_XMSS        _PATH_SSH_USER_DIR "/id_xmss"
./pathnames.h:80:#define _PATH_SSH_CLIENT_ID_ECDSA_SK    _PATH_SSH_USER_DIR "/id_ecdsa_sk"
./pathnames.h:81:#define _PATH_SSH_CLIENT_ID_ED25519_SK  _PATH_SSH_USER_DIR "/id_ed25519_sk"
./pathnames.h:89:#define _PATH_SSH_USER_CONFFILE         _PATH_SSH_USER_DIR "/config"
./pathnames.h:99:#define _PATH_SSH_USER_PERMITTED_KEYS   _PATH_SSH_USER_DIR "/authorized_keys"
./pathnames.h:102:#define _PATH_SSH_USER_PERMITTED_KEYS2  _PATH_SSH_USER_DIR "/authorized_keys2"
./pathnames.h:110:#define _PATH_SSH_USER_RC               _PATH_SSH_USER_DIR "/rc"
./readconf.c:1616:                                  "~/" _PATH_SSH_USER_DIR : SSHDIR, arg);
./ssh.c:1553:               strcmp(pw->pw_dir, "/") ? "/" : "", _PATH_SSH_USER_DIR);
./ssh-keygen.c:3609:        pw->pw_dir, _PATH_SSH_USER_DIR);

Patch it:

pathnames.h:60:#define _PATH_SSH_USER_DIR         ".local/share/ssh"

Make and install package with local changes:

$ makepkg -esi

Move configuration files

$ mv .ssh .local/share/ssh