mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Make AllowedUsers configurable in sshd_config (#8094)
docker/root/usr/bin/entrypoint already allows for the specification
of USER, USER_UID, USER_GID. But since AllowedUsers is hardcoded in
sshd_config, one cannot log in as a user different ftom git.
This change substitutes ${USER} for git in the sshd_config template.
Signed-off-by: Jeronimo Pellegrini <j_p@aleph0.info>
			
			
This commit is contained in:
		
				
					committed by
					
						
						Antoine GIRARD
					
				
			
			
				
	
			
			
			
						parent
						
							85f56546c4
						
					
				
				
					commit
					852b8e2d81
				
			@@ -25,7 +25,7 @@ ChallengeResponseAuthentication no
 | 
				
			|||||||
PasswordAuthentication no
 | 
					PasswordAuthentication no
 | 
				
			||||||
PermitEmptyPasswords no
 | 
					PermitEmptyPasswords no
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AllowUsers git
 | 
					AllowUsers ${USER}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Banner none
 | 
					Banner none
 | 
				
			||||||
Subsystem sftp /usr/lib/ssh/sftp-server
 | 
					Subsystem sftp /usr/lib/ssh/sftp-server
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,8 +3,6 @@
 | 
				
			|||||||
if [ "${USER}" != "git" ]; then
 | 
					if [ "${USER}" != "git" ]; then
 | 
				
			||||||
    # rename user
 | 
					    # rename user
 | 
				
			||||||
    sed -i -e "s/^git\:/${USER}\:/g" /etc/passwd
 | 
					    sed -i -e "s/^git\:/${USER}\:/g" /etc/passwd
 | 
				
			||||||
    # switch sshd config to different user
 | 
					 | 
				
			||||||
    sed -i -e "s/AllowUsers git$/AllowUsers ${USER}/g" /etc/ssh/sshd_config
 | 
					 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -z "${USER_GID}" ]; then
 | 
					if [ -z "${USER_GID}" ]; then
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user