(data *dto.SSHInfo)
| 268 | } |
| 269 | |
| 270 | func 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 | |
| 296 | func loadCurrentUserName() string { |
| 297 | currentUser, err := user.Current() |
no test coverage detected