I'm in the process of helping a customer migrate from an on-premises GitLab configuration to an AWS-hosted configuration. The on-premises GitLab is hosted on CentOS 7. The cloud-hosted GitLab will be hosted on Rocky or Alma 9.
Right now, the customer is doing User Acceptance Testing (UAT). They're running into some issues making legacy projects' repositories and associated automations work with the new GitLab service. One of these problems is that their developers are using keys in excess of five years' age. The OpenSSH server in CentOS 7 is elderly and, as a result, had been ok using these keys. However, because the maintainers of OpenSSH deprecated the use of SHA1-signed RSAv2 keys some time ago (and the OpenSSH versions in EL 8&9 and derivatives updated the shipped OpenSSH server version), the OpenSSH server in RHEL 9-derived distros just is not having it with these elderly keys.
The developer was suspicious of my claim that this was the source of their git-over-ssh problems. I needed to be able to prove things to them, but I haven't had a Linux host capable of creating SHA1-signed RSAv2 SSH keys in quite a while. So, "what to do"?
Turns out, "Docker to the rescue". Not wanting to dick with the overhead of writing a Dockerfile, I simply did it interactively:
- Login to Dockerhub …to reduce the likelihood of getting errors around too many anonymous fetch-attempts in a given timespan
- Launch an interactive CentOS 6 container with a volume attached so that I could easily save out any generated keys:
$ docker run -it -v $( pwd ):/save_dir --entrypoint /bin/bash centos:6
- Install the openssh-clients RPM:
# yum install -y --disablerepo=* --enablerepo=C6.9* openssh-clients
- Generate a suitable key:
# ssh-keygen \ -t rsa \ -b 2048 \ -C "SHA1-signed key generated on CentOS 6" \ -f /save_dir/id_rsa_sha1-signed
- Exit from the running container (<CTRL>-D suffices)
- Fix any ownership/permission problems on the new files
- Register the new key with GitLab
- Attempt a git clone using the SSH URL and ensure that I'm using the newly-generated key
$ git clone \ -c core.sshCommand="/usr/bin/ssh -i $( pwd )/id_rsa_sha1-signed" \ git@<GIT_SERVER_FQD>:<REPOSITORY_PATH>
- Receive an error like:
Cloning into '<REPO_NAME>'... git@<GIT_SERVER_FQD>: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
- Create a SHA2-signed RSAv2 key like:
$ ssh-keygen -t rsa-sha2-512
- Register the SHA2-signed key to GitLab
- Attempt the same `git clone …`operation (minus the `core.sshCommand` stuff) that had peviously failed with the SHA1-signed RSAv2 key.
- This time, the clone operation succeeds