MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / loadSSHConfigInfo

Function loadSSHConfigInfo

agent/app/service/ssh.go:270–294  ·  view source on GitHub ↗
(data *dto.SSHInfo)

Source from the content-addressed store, hash-verified

268}
269
270func loadSSHConfigInfo(data *dto.SSHInfo) {
271 directives, _, err := parseSSHConfigTree(sshPath)
272 if err != nil {
273 data.Message = err.Error()
274 data.IsActive = false
275 return
276 }
277
278 if port := strings.Join(loadSSHPortValues(directives), ","); port != "" {
279 data.Port = port
280 }
281 data.ListenAddress = strings.Join(loadSSHDirectiveValues(directives, "ListenAddress"), ",")
282 if value, ok := loadFirstSSHDirectiveValue(directives, "PasswordAuthentication"); ok {
283 data.PasswordAuthentication = value
284 }
285 if value, ok := loadFirstSSHDirectiveValue(directives, "PubkeyAuthentication"); ok {
286 data.PubkeyAuthentication = value
287 }
288 if value, ok := loadFirstSSHDirectiveValue(directives, "PermitRootLogin"); ok {
289 data.PermitRootLogin = strings.ReplaceAll(value, "prohibit-password", "without-password")
290 }
291 if value, ok := loadFirstSSHDirectiveValue(directives, "UseDNS"); ok {
292 data.UseDNS = value
293 }
294}
295
296func loadCurrentUserName() string {
297 currentUser, err := user.Current()

Callers 1

GetSSHInfoMethod · 0.85

Calls 5

parseSSHConfigTreeFunction · 0.85
loadSSHPortValuesFunction · 0.85
loadSSHDirectiveValuesFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected