Redundant, zombie key in authorized keys prevents SSH key based authentication

Edit: (Prior title)Seems like SSH public/private keys need to be identical for each local username.

After the help of @AndreKR we found that the problem was not because of the previously claimed identical local username, but rather that there was a duplicate key in the authorized_keys file, which was not visible in the Gitlab Web interface, nor the DB. Not sure how this happened, (Perhaps I double clicked when registering a key?) however It should be fixed now!

Summary

I have two machines, and both machines have the same username. Each machine had different public/private keys I added both public keys onto gitlab. After the first machine cloned and pushed without a problem the second machine kept on getting a `Permission denied (publickey). fatal: Could not read from remote repository.

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

When I copied the private and public key of the first machine onto the second machine and did the same push, it worked without a problem.

Steps to reproduce

  • Have two machines with same username and different keys
  • First push onto a repo with the first machine
  • Pushing from the second repo (to a different repo) should cause the Permission denied(publickey) error.

Expected behavior

I expect both keys to work from different machines. At least on github there was not such a problem.

Actual behavior

I get a permission denied

Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's very hard to read otherwise.)

Output of checks

Results of GitLab application Check

yes                                                                                                                                                                                                   
Repo paths access is drwxrws---?                                                                                                                                                                      
Checking GitLab Shell ...                                                                                                                                                                             
                                                                                                                                                                                                      
GitLab Shell version >= 3.6.1 ? ... OK (3.6.1)                                                                                                                                                        
Repo base directory exists?                                                                                                                                                                           
default... yes                                                                                                                                                                                        
Repo storage directories are symlinks?                                                                                                                                                                
default... no                                                                                                                                                                                         
Repo paths owned by git:git?                                                                                                                                                                          
default... hooks directories in repos are links: ... default... yes                                                                                                                                   
                                                                                                                                                                                                      
3/2 ... repository is empty                                                                                                                                                                           
2/3 ... ok                                                                                                                                                                                            
2/4 ... ok                                                                                                                                                                                            
2/5 ... repository is empty                                                                                                                                                                           
Running /home/git/gitlab-shell/bin/check                                                                                                                                                              
Check GitLab API access: OK                                                                                                                                                                           
Access to /home/git/.ssh/authorized_keys: OK                                                                                                                                                          
Send ping to redis server: OK                                                                                                                                                                         
gitlab-shell self-check successful                                                                                                                                                                    
                                                                                                                                                                                                      
Checking GitLab Shell ... Finished                                                                                                                                                                    
                                                                                                                                                                                                      
Checking Sidekiq ...                                                                                                                                                                                  
                                                                                                                                                                                                      
Running? ... yes                                                                                                                                                                                      
Number of Sidekiq processes ... 1                                                                                                                                                                     
                                                                                                                                                                                                      
Checking Sidekiq ... Finished                                                                                                                                                                         
                                                                                                                                                                                                      
Checking Reply by email ...                                                                                                                                                                           
                                                                                                                                                                                                      
Reply by email is disabled in config/gitlab.yml                                                                                                                                                       
                                                                                                                                                                                                      
Checking Reply by email ... Finished                                                                                                                                                                  
                                                                                                                                                                                                      
Checking LDAP ...                                                                                                                                                                                     
                                                                                                                                                                                                      
LDAP is disabled in config/gitlab.yml                                                                                                                                                                 
                                                                                                                                                                                                      
Checking LDAP ... Finished                                                                                                                                                                            
                                                                                                                                                                                                      
Checking GitLab ...                                                                                                                                                                                   
                                                                                                                                                                                                      
Git configured with autocrlf=input? ... yes                                                                                                                                                           
Database config exists? ... yes                                                                                                                                                                       
All migrations up? ... yes                                                                                                                                                                            
Database contains orphaned GroupMembers? ... no                                                                                                                                                       
GitLab config exists? ... yes                                                                                                                                                                         
GitLab config outdated? ... no                                                                                                                                                                        
Log directory writable? ... yes                                                                                                                                                                       
Tmp directory writable? ... yes                                                                                                                                                                       
Uploads directory setup correctly? ... skipped (no tmp uploads folder yet)                                                                                                                            
Init script exists? ... yes                                                                                                                                                                           
Init script up-to-date? ... yes                                                                                                                                                                       
projects have namespace: ...                                                                                                                                                                          
3/2 ... yes                                                                                                                                                                                           
2/3 ... yes                                                                                                                                                                                           
2/4 ... yes                                                                                                                                                                                           
2/5 ... yes                                                                                                                                                                                           
Redis version >= 2.8.0? ... yes                                                                                                                                                                       
Ruby version >= 2.1.0 ? ... yes (2.3.1)                                                                                                                                                               
Your git bin path is "/usr/bin/git"                                                                                                                                                                   
Git version >= 2.7.3 ? ... yes (2.10.0)                                                                                                                                                               
Active users: 2                                                                                                                                                                                       
                                                                                                                                                                                                      
Checking GitLab ... Finished 

Results of GitLab environment info

System information                                                                                                                                                                                    
System:         Ubuntu 14.04                                                                                                                                                                          
Current User:   git                                                                                                                                                                                   
Using RVM:      no                                                                                                                                                                                    
Ruby Version:   2.3.1p112                                                                                                                                                                             
Gem Version:    2.5.1                                                                                                                                                                                 
Bundler Version:1.13.2                                                                                                                                                                                
Rake Version:   10.5.0                                                                                                                                                                                
Sidekiq Version:4.1.4                                                                                                                                                                                 
                                                                                                                                                                                                      
GitLab information                                                                                                                                                                                    
Version:        8.12.3                                                                                                                                                                                
Revision:       467e1ca                                                                                                                                                                               
Directory:      /home/git/gitlab                                                                                                                                                                      
DB Adapter:     mysql2                                                                                                                                                                                
URL:            https://cabackup.kaist.ac.kr:19080                                                                                                                                                    
HTTP Clone URL: https://cabackup.kaist.ac.kr:19080/some-group/some-project.git                                                                                                                        
SSH Clone URL:  ssh://git@cabackup.kaist.ac.kr:19022/some-group/some-project.git                                                                                                                      
Using LDAP:     no                                                                                                                                                                                    
Using Omniauth: no                                                                                                                                                                                    
                                                                                                                                                                                                      
GitLab Shell                                                                                                                                                                                          
Version:        3.6.1                                                                                                                                                                                 
Repository storage paths:                                                                                                                                                                             
- default:      /home/git/data/repositories/                                                                                                                                                          
Hooks:          /home/git/gitlab-shell/hooks/                                                                                                                                                         
Git:            /usr/bin/git 

Possible fixes

Copy the public/private key from the first machine onto the second machine.