Skip to content

Commit

Permalink
moved authz_keys binds to deploy stage
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Dec 9, 2021
1 parent a785adf commit bbf0ec0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions nodes/srl/srl.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,6 @@ func (s *srl) Init(cfg *types.NodeConfig, opts ...nodes.NodeOption) error {
topoPath := filepath.Join(s.cfg.LabDir, "topology.yml")
s.cfg.Binds = append(s.cfg.Binds, fmt.Sprint(topoPath, ":/tmp/topology.yml:ro"))

// mount authorized_keys file to enable passwordless login
authzKeysPath := filepath.Join(filepath.Dir(s.cfg.LabDir), "authorized_keys")
log.Warn("authzKeysPath:", authzKeysPath)
if utils.FileExists(authzKeysPath) {
log.Warn("authzKeyFile exists, mounting")
s.cfg.Binds = append(s.cfg.Binds, fmt.Sprint(authzKeysPath, ":/root/.ssh/authorized_keys:ro"))
s.cfg.Binds = append(s.cfg.Binds, fmt.Sprint(authzKeysPath, ":/home/linuxadmin/.ssh/authorized_keys:ro"))
s.cfg.Binds = append(s.cfg.Binds, fmt.Sprint(authzKeysPath, ":/home/admin/.ssh/authorized_keys:ro"))
}

return nil
}

Expand Down Expand Up @@ -218,6 +208,16 @@ func (s *srl) PreDeploy(configName, labCADir, labCARoot string) error {
}
}

// mount authorized_keys file to enable passwordless login
authzKeysPath := filepath.Join(filepath.Dir(s.cfg.LabDir), "authorized_keys")
log.Warn("authzKeysPath:", authzKeysPath)
if utils.FileExists(authzKeysPath) {
log.Warn("authzKeyFile exists, mounting")
s.cfg.Binds = append(s.cfg.Binds, fmt.Sprint(authzKeysPath, ":/root/.ssh/authorized_keys:ro"))
s.cfg.Binds = append(s.cfg.Binds, fmt.Sprint(authzKeysPath, ":/home/linuxadmin/.ssh/authorized_keys:ro"))
s.cfg.Binds = append(s.cfg.Binds, fmt.Sprint(authzKeysPath, ":/home/admin/.ssh/authorized_keys:ro"))
}

return s.createSRLFiles()
}

Expand Down

0 comments on commit bbf0ec0

Please sign in to comment.