Can pull from GitLab project but cannot push when other projects work fine

I have a weird situation with GitLab. I am working with an enterprise edition hosted by my institution. There is <url>/groupA/projectA and <url>/groupB/projectB. Both projects use the default permission sets for reporter, developer, maintainer, etc. In both projects, I am a developer. I use ssh authentication for both. When I do git remote -v locally in each project, the only difference in the output is git@<url>:groupA/projectA vs. git@<url>:groupB/projectB.

Now the issue: everything works fine for project A. For project B, I can clone and pull without issue. I can also create branches, commits, and merge requests in the browser. However, creating a branch locally and pushing it results in the following message:

remote:
remote: ========================================================================
remote:
remote: ERROR: You are not allowed to push code to this project.

remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I’m really at a loss here. I tried creating a fresh set of ssh keys and replacing the old one. The same behavior occurs: I can work fine with project A but cannot push to project B. The owner of project B has double checked all the settings and sees nothing that should prevent me from pushing. ssh git@<url> gives the expected message:

PTY allocation request failed on channel 0
Welcome to GitLab, <username>!
Connection to <url> closed.

Any suggestions are welcome. I’m a very experienced Git and GitLab user and this is the first time I’ve encountered this. No suggestions on other pages have solved the problem yet, unfortunately.

Of course, right after posting this I finally found a solution I missed on another post: Unable to push to Gitlab, You are not allowed to push code to this project

The actual solution that worked for me was to create a second key and then do what James C said in his comment. Copied here for convenience:

I had something similar happen but I was trying to add a second gitlab account to my system. I had two ssh keys and tried to create an ssh config that used the second key. For some reason, even though it did try to use the key when I tested with ssh -Tvvv [email protected], it kept logging me in with the wrong identity. I ended up finding a solution on gitlab’s documentation page and did this to make it work: git config core.sshCommand “ssh -o IdentitiesOnly=yes -i ~/.ssh/private-key-filename-for-this-repository -F /dev/null” –
James C
CommentedJul 7, 2020 at 20:10

Edit

To further expound on what was happening (I didn’t understand this until it was fixed): I used to work at this institution under @username1; I no longer work there, but work with them as a collaborator under @username2. It turns out the ssh keys I’m using are associated with @username1, which was a member of projectA but not projectB. So even though I can’t even login to the web interface using @username1 anymore, it was still authenticating me as @username1 over ssh. I think projectB is set to be sufficiently public that it meant I could pull as @username1 and edit things in the web interfaces as @username2, but could not push as @username1. This is probably a very niche circumstance, but I wanted to share my findings to help some other confused soul in the future!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật