Remove old comments; Count auth mechanisms independently
This commit is contained in:
26
src/main.go
26
src/main.go
@ -14,15 +14,6 @@ import (
|
||||
|
||||
const Version = "1.3.0"
|
||||
|
||||
// Config and SSH types are now in separate packages
|
||||
|
||||
// SSH connection methods are now in ssh.go
|
||||
|
||||
// YAML processing is now handled by the config package
|
||||
|
||||
// SSH helper functions are now in ssh.go
|
||||
|
||||
// processDevice handles backup processing for a single device
|
||||
func processDevice(hostname string, deviceConfig Device, commands []string, excludePatterns []string, password, keyFile string, port int, outputDir string) bool {
|
||||
// Create backup instance
|
||||
backup := NewRouterBackup(hostname, deviceConfig.Address, deviceConfig.User, password, keyFile, port)
|
||||
@ -82,17 +73,24 @@ func main() {
|
||||
}
|
||||
|
||||
// Check authentication setup
|
||||
if password == "" && keyFile == "" {
|
||||
hasAuth := 0
|
||||
if os.Getenv("SSH_AUTH_SOCK") != "" {
|
||||
fmt.Println("Using SSH agent for authentication")
|
||||
} else {
|
||||
keyFile = findDefaultSSHKey()
|
||||
hasAuth++
|
||||
}
|
||||
if keyFile == "" {
|
||||
log.Fatal("No SSH key found and no password provided")
|
||||
} else {
|
||||
keyFile = findDefaultSSHKey()
|
||||
if keyFile != "" {
|
||||
fmt.Printf("Using SSH key: %s\n", keyFile)
|
||||
hasAuth++
|
||||
}
|
||||
}
|
||||
if password != "" {
|
||||
fmt.Println("Using --password for authentication")
|
||||
hasAuth++
|
||||
}
|
||||
if hasAuth == 0 {
|
||||
log.Fatal("No authentication mechanisms found.")
|
||||
}
|
||||
|
||||
// Process devices
|
||||
|
Reference in New Issue
Block a user