@@ -104,6 +104,7 @@ func (s *sshServer) handleConn(ctx context.Context, conn net.Conn) {
104
104
args = append (args ,
105
105
"-ieD" , "-f/dev/null" ,
106
106
"-oProtocol 2" ,
107
+ "-oAllowUsers root gitpod" ,
107
108
"-oPasswordAuthentication no" ,
108
109
"-oChallengeResponseAuthentication no" ,
109
110
"-oPermitRootLogin yes" ,
@@ -158,6 +159,7 @@ func (s *sshServer) handleConn(ctx context.Context, conn net.Conn) {
158
159
159
160
log .WithField ("args" , args ).Debug ("sshd flags" )
160
161
cmd := exec .CommandContext (ctx , openssh , args ... )
162
+ cmd = runAsGitpodUser (cmd )
161
163
cmd .Env = s .envvars
162
164
cmd .ExtraFiles = []* os.File {socketFD }
163
165
cmd .Stderr = os .Stderr
@@ -252,30 +254,6 @@ func ensureSSHDir(cfg *Config) error {
252
254
return nil
253
255
}
254
256
255
- func ensurePrivsepDir () error {
256
- // Privilege separation, or privsep, is method in OpenSSH by which
257
- // operations that require root privilege are performed by a separate
258
- // privileged monitor process.
259
- // see detail: https://github.com/openssh/openssh-portable/blob/master/README.privsep
260
- privsepPath := "/var/empty"
261
- err := os .MkdirAll (privsepPath , 0o755 )
262
- if err != nil {
263
- return xerrors .Errorf ("cannot create privsep path: %w" , err )
264
- }
265
- return nil
266
- }
267
-
268
- func ensureSSHCAFile (cfg * Config , caPath string ) error {
269
- if cfg .SSHGatewayCAPublicKey == "" {
270
- return nil
271
- }
272
- err := os .WriteFile (caPath , []byte (cfg .SSHGatewayCAPublicKey ), 0o644 )
273
- if err != nil {
274
- return xerrors .Errorf ("cannot write ssh ca pem: %w" , err )
275
- }
276
- return nil
277
- }
278
-
279
257
func configureSSHDefaultDir (cfg * Config ) {
280
258
if cfg .RepoRoot == "" {
281
259
log .Error ("cannot configure ssh default dir with empty repo root" )
0 commit comments