()
| 169 | } |
| 170 | |
| 171 | func backupSSHConfig() (string, error) { |
| 172 | configPath := sshConfigPath() |
| 173 | |
| 174 | // Check if config exists |
| 175 | if _, err := os.Stat(configPath); os.IsNotExist(err) { |
| 176 | // No config file, no backup needed |
| 177 | return "", nil |
| 178 | } |
| 179 | |
| 180 | // Create timestamped backup |
| 181 | timestamp := time.Now().Unix() |
| 182 | backupPath := fmt.Sprintf("%s.bak.%d", configPath, timestamp) |
| 183 | |
| 184 | // Copy file |
| 185 | if err := copyFile(configPath, backupPath); err != nil { |
| 186 | return "", fmt.Errorf("failed to create backup: %w", err) |
| 187 | } |
| 188 | |
| 189 | return backupPath, nil |
| 190 | } |
| 191 | |
| 192 | func readSSHConfigLines() ([]string, error) { |
| 193 | configPath := sshConfigPath() |
no test coverage detected