Gitlab erroneous “project could not be found"

I have an established account on Gitlab. I created a new empty repository. I copied exactly the instructions to push an existing folder to it.

cd existing_folder
git init --initial-branch=main
git remote add origin git@gitlab.com:Joymaker3/CatandMouse.git
git add .
git commit -m "Initial commit"
git push --set-upstream origin main

It all worked until the final push instruction, and then it failed, giving me:

% git push --set-upstream origin main
remote: 
remote: ========================================================================
remote: 
remote: ERROR: The project you were looking for could not be found or you don't have permission to view it.

I went and looked and saw that my SSH key was expired. So I created another one and pasted it into the appropriate place at Gitlab. Then I tried the push again. Exact same error.

Okay, maybe there’s something funky with the new repository. I tried cloning an existing repository which is well known to work, using its SSH URL. Same error!

Next step: check the SSH connectivity

% ssh -vT git@gitlab.com
OpenSSH_9.4p1, LibreSSL 3.3.6
debug1: Reading configuration data /Users/ken/.ssh/config
debug1: /Users/ken/.ssh/config line 9: Applying options for *
debug1: /Users/ken/.ssh/config line 14: Applying options for gitlab.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to gitlab.com port 22.
debug1: Connection established.
debug1: identity file /Users/ken/.ssh/id_ed25519 type 3
debug1: identity file /Users/ken/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.4
debug1: Remote protocol version 2.0, remote software version GitLab-SSHD
debug1: compat_banner: no match: GitLab-SSHD
debug1: Authenticating to gitlab.com:22 as 'git'
debug1: load_hostkeys: fopen /Users/ken/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw
debug1: load_hostkeys: fopen /Users/ken/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host 'gitlab.com' is known and matches the ECDSA host key.
debug1: Found key in /Users/ken/.ssh/known_hosts:28
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: ssh_fetch_identitylist: agent contains no identities
debug1: Will attempt key: /Users/ken/.ssh/id_ed25519 ED25519 SHA256:OfDLrUCWHOxRC1OltBjAU4IJdo8xzTCkz4H8bHbswQA explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-256,rsa-sha2-512,ssh-rsa,ssh-dss>
debug1: kex_input_ext_info: ping@openssh.com (unrecognised)
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/ken/.ssh/id_ed25519 ED25519 SHA256:OfDLrUCWHOxRC1OltBjAU4IJdo8xzTCkz4H8bHbswQA explicit
debug1: Server accepts key: /Users/ken/.ssh/id_ed25519 ED25519 SHA256:OfDLrUCWHOxRC1OltBjAU4IJdo8xzTCkz4H8bHbswQA explicit
Authenticated to gitlab.com ([172.65.251.78]:22) using "publickey".
debug1: channel 0: new session [client-session] (inactive timeout: 0)
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: Sending environment.
debug1: channel 0: setting env LANG = "en_US.UTF-8"
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Welcome to GitLab, @Joymaker2!
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2156, received 1612 bytes, in 0.1 seconds
Bytes per second: sent 19642.5, received 14686.3
debug1: Exit status 0

Looks like it connected! So is something wrong with Gitlab’s suggested URL? I’ve been giving up and using https in the past, but I’d really like to get this right!

Host gitlab.com
  HostName gitlab.com
  User git
  IdentityFile ~/.ssh/id_ed25519

Confirm Git Remote URL

Verify that the remote URL is correct. Run the following command in your local repository:

git remote -v

Ensure that it shows the SSH URL (e.g., git@gitlab.com:Joymaker3/CatandMouse.git). If it’s incorrect, update it using:

git remote set-url origin git@gitlab.com:Joymaker3/CatandMouse.git

Check for GitLab Groups

If the repository belongs to a group, ensure you have access to that group as well. You can check this by navigating to the group in GitLab and looking at the group members.

Try Cloning Again

Since you mentioned trying to clone an existing repository but got the same error, try cloning again, ensuring you’re using the SSH URL:

git clone git@gitlab.com:Joymaker3/ExistingRepo.git

SSH Key Agent

Make sure that your SSH key is being added to the SSH agent. You can do this by running:

ssh-add ~/.ssh/id_ed25519

GitLab Status

Sometimes, GitLab may experience outages or issues. Check GitLab’s status page to ensure there are no ongoing incidents.

Use HTTPS as a Workaround

If SSH continues to cause issues and you need to push code, you can temporarily use the HTTPS URL for pushing:

git remote set-url origin https://gitlab.com/Joymaker3/CatandMouse.git