machineconfig 5.84__py3-none-any.whl → 5.86__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of machineconfig might be problematic. Click here for more details.

@@ -33,8 +33,9 @@ config2 = {this = '~/.cli-m365-all-connections.json', to_this = '~/dotfiles/cred
33
33
  config3 = {this = '~/.cli-m365-connection.json', to_this = '~/dotfiles/creds/tokens/.cli-m365-connection.json'}
34
34
  # config2 = {this = '~/.cli-m365-tokens.json', to_this = '~/dotfiles/creds/tokens/.cli-m365-tokens.json'}
35
35
 
36
- [bash_linux]
37
- bashrc = {this = '~/.inputrc', to_this = '~/dotfiles/shells/bash/.inputrc'}
36
+ # [bash_linux]
37
+ # bashrc = {this = '~/.inputrc', to_this = '~/dotfiles/shells/bash/.inputrc'}
38
+
38
39
  [remmina]
39
40
  data = {this = '~/.var/app/org.remmina.Remmina/data/remmina', to_this = '~/dotfiles/creds/RDP/remmina/data/remmina'}
40
41
 
@@ -51,7 +51,7 @@ def pwsh_theme():
51
51
  import subprocess
52
52
  subprocess.run(["pwsh", "-File", str(file)])
53
53
 
54
- def copy_assets(which: Literal["scripts", "settings", "both"] = typer.Option(..., "--which", "-w", help="Which assets to copy")):
54
+ def copy_assets(which: Literal["scripts", "settings", "both"] = typer.Argument(..., help="Which assets to copy")):
55
55
  """🔗 Copy asset files from library to machine."""
56
56
  import machineconfig.profile.create_helper as create_helper
57
57
  match which:
@@ -64,18 +64,18 @@ def copy_assets(which: Literal["scripts", "settings", "both"] = typer.Option(...
64
64
 
65
65
  def get_app():
66
66
  config_apps = typer.Typer(help="⚙️ [c] configuration subcommands", no_args_is_help=True)
67
- config_apps.command("private", no_args_is_help=True, help="🔗 [p] Manage private configuration files.")(private)
68
- config_apps.command("p", no_args_is_help=True, help="Manage private configuration files.", hidden=True)(private)
69
- config_apps.command("public", no_args_is_help=True, help="🔗 [u] Manage public configuration files.")(public)
70
- config_apps.command("u", no_args_is_help=True, help="Manage public configuration files.", hidden=True)(public)
67
+ config_apps.command("private", no_args_is_help=True, help="🔗 [v] Manage private configuration files.")(private)
68
+ config_apps.command("v", no_args_is_help=True, hidden=True)(private)
69
+ config_apps.command("public", no_args_is_help=True, help="🔗 [b] Manage public configuration files.")(public)
70
+ config_apps.command("b", no_args_is_help=True, help="Manage public configuration files.", hidden=True)(public)
71
71
  config_apps.command("dotfile", no_args_is_help=True, help="🔗 [d] Manage dotfiles.")(dotfile)
72
- config_apps.command("d", no_args_is_help=True, help="Manage dotfiles.", hidden=True)(dotfile)
72
+ config_apps.command("d", no_args_is_help=True, hidden=True)(dotfile)
73
73
  config_apps.command("shell", no_args_is_help=False, help="🔗 [s] Configure your shell profile.")(shell)
74
74
  config_apps.command("s", no_args_is_help=False, help="Configure your shell profile.", hidden=True)(shell)
75
- config_apps.command("path", no_args_is_help=False, help="📚 [a] NAVIGATE PATH variable with TUI")(path)
76
- config_apps.command("a", no_args_is_help=False, help="NAVIGATE PATH variable with TUI", hidden=True)(path)
75
+ config_apps.command("path", no_args_is_help=False, help="📚 [p] NAVIGATE PATH variable with TUI")(path)
76
+ config_apps.command("p", no_args_is_help=False, help="NAVIGATE PATH variable with TUI", hidden=True)(path)
77
77
  config_apps.command("pwsh-theme", no_args_is_help=False, help="🔗 [t] Select powershell prompt theme.")(pwsh_theme)
78
78
  config_apps.command("t", no_args_is_help=True, help="Select powershell prompt theme.", hidden=True)(pwsh_theme)
79
- config_apps.command("copy-assets", no_args_is_help=True, help="🔗 [c] Copy asset files from library to machine.")
79
+ config_apps.command("copy-assets", no_args_is_help=True, help="🔗 [c] Copy asset files from library to machine.", hidden=False)(copy_assets)
80
80
  config_apps.command("c", no_args_is_help=True, help="Copy asset files from library to machine.", hidden=True)(copy_assets)
81
81
  return config_apps
@@ -49,7 +49,8 @@ def debug_ssh():
49
49
  import machineconfig.scripts.python.nw.ssh_debug_linux as helper
50
50
  helper.ssh_debug_linux()
51
51
  elif system() == "Windows":
52
- raise NotImplementedError("SSH debug for Windows is not implemented yet.")
52
+ import machineconfig.scripts.python.nw.ssh_debug_windows as helper
53
+ helper.ssh_debug_windows()
53
54
  else:
54
55
  raise NotImplementedError(f"Platform {system()} is not supported.")
55
56
 
@@ -166,7 +166,7 @@ def get_app():
166
166
  repos_apps.command(name="P", help="Pull changes across repositories", hidden=True)(pull)
167
167
  repos_apps.command(name="commit", help="💾 [c] Commit changes across repositories")(commit)
168
168
  repos_apps.command(name="c", help="Commit changes across repositories", hidden=True)(commit)
169
- repos_apps.command(name="sync", help="🔄 [s] Pull, commit, and push changes across repositories")(sync)
169
+ repos_apps.command(name="sync", help="🔄 [y] Pull, commit, and push changes across repositories")(sync)
170
170
  repos_apps.command(name="s", help="Pull, commit, and push changes across repositories", hidden=True)(sync)
171
171
  repos_apps.command(name="analyze", help="📊 [a] Analyze repository development over time")(analyze)
172
172
  repos_apps.command(name="a", help="Analyze repository development over time", hidden=True)(analyze)
@@ -5,7 +5,18 @@ from typing import Optional
5
5
 
6
6
  def update():
7
7
  """🔄 UPDATE uv and machineconfig"""
8
- code = """
8
+ # from machineconfig.utils.source_of_truth import LIBRARY_ROOT
9
+ # repo_root = LIBRARY_ROOT.parent.parent
10
+ from pathlib import Path
11
+ if Path.home().joinpath("code", "machineconfig").exists():
12
+ code = """
13
+ uv self update
14
+ cd ~/code/machineconfig
15
+ git pull
16
+ uv tool install --upgrade --editable $HOME/code/machineconfig
17
+ """
18
+ else:
19
+ code = """
9
20
  uv self update
10
21
  uv tool install --upgrade machineconfig
11
22
  """
@@ -85,7 +96,7 @@ def get_app():
85
96
  cli_app.command("I", no_args_is_help=False, help="CLONE machienconfig locally and incorporate to shell profile for faster execution and nightly updates.", hidden=True)(install)
86
97
  cli_app.command("navigate", no_args_is_help=False, help="📚 [n] NAVIGATE command structure with TUI")(navigate)
87
98
  cli_app.command("n", no_args_is_help=False, help="NAVIGATE command structure with TUI", hidden=True)(navigate)
88
- cli_app.command("python", no_args_is_help=False, help="🐍 [c] python command/file in the machineconfig environment")(run_python)
99
+ cli_app.command("python", no_args_is_help=False, help="🐍 [c] python command/file in the machineconfig environment", context_settings={"show_help_on_error": True})(run_python)
89
100
  cli_app.command("c", no_args_is_help=False, help="RUN python command/file in the machineconfig environment", hidden=True)(run_python)
90
101
  cli_app.command("readme", no_args_is_help=False, help="📚 [r] render readme markdown in terminal.")(readme)
91
102
  cli_app.command("r", no_args_is_help=False, hidden=True)(readme)
@@ -22,7 +22,7 @@ def _process_single_repo(expanded_path: Path, allow_password_prompt: bool) -> tu
22
22
  try:
23
23
  repo = git.Repo(str(expanded_path), search_parent_directories=True)
24
24
  # Update repository and get detailed results
25
- result = update_repository(repo, allow_password_prompt=allow_password_prompt, auto_sync=True)
25
+ result = update_repository(repo, allow_password_prompt=allow_password_prompt, auto_uv_sync=True)
26
26
 
27
27
  # Keep track of repos with dependency changes for additional uv sync
28
28
  repo_path = None
@@ -11,7 +11,7 @@ AGENTS_DIR="$REPO_ROOT/.ai/agents/$JOB_NAME"
11
11
  LAYOUT_PATH_UNBALANCED="$REPO_ROOT/.ai/agents/$JOB_NAME/layout_unbalanced.json"
12
12
 
13
13
  # agents make-todo --output-path $CONTEXT_PATH
14
- agents create \
14
+ ag create \
15
15
  --context-path "$CONTEXT_PATH" \
16
16
  --tasks-per-prompt 1 \
17
17
  --machine docker \
@@ -27,6 +27,6 @@ agents create \
27
27
  # sessions balance-load $LAYOUT_PATH --max-thresh 6 --breaking-method moreLayouts --thresh-type number --output-path $LAYOUT_BALANCED_PATH
28
28
  # sessions run $LAYOUT_BALANCED_PATH --kill-upon-completion
29
29
 
30
- sessions run $LAYOUT_PATH_UNBALANCED
30
+ ses run $LAYOUT_PATH_UNBALANCED
31
31
 
32
32
  # agents collect $AGENTS_DIR "$REPO_ROOT/.ai/agents/$JOB_NAME/collected.txt"
@@ -1,12 +1,12 @@
1
1
 
2
2
  import typer
3
3
  from typing import Optional, Literal
4
-
4
+ from pathlib import Path
5
5
 
6
6
 
7
7
  def main(
8
8
  cloud: Optional[str] = typer.Option(None, "--cloud", "-c", help="Cloud storage profile name. If not provided, uses default from config."),
9
- repo: Optional[str] = typer.Option(None, "--repo", "-r", help="Path to the local repository. Defaults to current working directory."),
9
+ repo: Optional[str] = typer.Option(Path.cwd().as_posix(), "--repo", "-r", help="Path to the local repository. Defaults to cwd."),
10
10
  message: Optional[str] = typer.Option(None, "--message", "-m", help="Commit message for local changes."),
11
11
  on_conflict: Literal["ask", "push-local-merge", "overwrite-local", "stop-on-conflict", "remove-rclone-conflict"] = typer.Option("ask", "--on-conflict", "-oc", help="Action to take on merge conflict. Default is 'ask'."),
12
12
  pwd: Optional[str] = typer.Option(None, "--password", help="Password for encryption/decryption of the remote repository."),
@@ -0,0 +1,338 @@
1
+
2
+
3
+ from platform import system
4
+ from machineconfig.utils.path_extended import PathExtended
5
+ from rich.console import Console
6
+ from rich.panel import Panel
7
+ from rich import box
8
+ import subprocess
9
+ import os
10
+
11
+ console = Console()
12
+
13
+
14
+ def ssh_debug_windows() -> dict[str, dict[str, str | bool]]:
15
+ """
16
+ Comprehensive SSH debugging function that checks for common pitfalls on Windows systems.
17
+
18
+ Returns a dictionary with diagnostic results for each check performed.
19
+ """
20
+ if system() != "Windows":
21
+ console.print(Panel("❌ This function is only supported on Windows systems", title="[bold red]Error[/bold red]", border_style="red"))
22
+ raise NotImplementedError("ssh_debug_windows is only supported on Windows")
23
+
24
+ console.print(Panel("🔍 SSH DEBUG - COMPREHENSIVE DIAGNOSTICS (WINDOWS)", box=box.DOUBLE_EDGE, title_align="left"))
25
+
26
+ results: dict[str, dict[str, str | bool]] = {}
27
+ issues_found: list[str] = []
28
+
29
+ ssh_dir = PathExtended.home().joinpath(".ssh")
30
+ authorized_keys = ssh_dir.joinpath("authorized_keys")
31
+
32
+ console.print(Panel("🔐 Checking SSH directory and authorized_keys...", title="[bold blue]File Permissions[/bold blue]", border_style="blue"))
33
+
34
+ if not ssh_dir.exists():
35
+ results["ssh_directory"] = {"status": "error", "message": "~/.ssh directory does not exist", "action": "Create with: mkdir %USERPROFILE%\\.ssh"}
36
+ issues_found.append("SSH directory missing")
37
+ console.print(Panel("❌ ~/.ssh directory does not exist\n💡 Run: mkdir %USERPROFILE%\\.ssh", title="[bold red]Critical Issue[/bold red]", border_style="red"))
38
+ else:
39
+ results["ssh_directory"] = {"status": "ok", "message": "~/.ssh directory exists", "action": ""}
40
+ console.print(Panel("✅ ~/.ssh directory exists", title="[bold green]OK[/bold green]", border_style="green"))
41
+
42
+ try:
43
+ icacls_check = subprocess.run(["icacls", str(ssh_dir)], capture_output=True, text=True, check=False)
44
+ if icacls_check.returncode == 0:
45
+ icacls_output = icacls_check.stdout
46
+ if "BUILTIN\\Administrators:(OI)(CI)(F)" in icacls_output or "NT AUTHORITY\\SYSTEM:(OI)(CI)(F)" in icacls_output:
47
+ console.print(Panel(f"ℹ️ ~/.ssh permissions:\n{icacls_output[:300]}", title="[bold blue]Info[/bold blue]", border_style="blue"))
48
+ except Exception:
49
+ pass
50
+
51
+ if not authorized_keys.exists():
52
+ results["authorized_keys"] = {"status": "warning", "message": "authorized_keys file does not exist", "action": "Create authorized_keys file and add public keys"}
53
+ issues_found.append("authorized_keys missing")
54
+ console.print(Panel("⚠️ authorized_keys file does not exist\n💡 Add your public key to %USERPROFILE%\\.ssh\\authorized_keys", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
55
+ else:
56
+ try:
57
+ key_count = len([line for line in authorized_keys.read_text(encoding="utf-8").split("\n") if line.strip()])
58
+ results["authorized_keys"] = {"status": "ok", "message": f"authorized_keys exists, contains {key_count} key(s)", "action": ""}
59
+ console.print(Panel(f"✅ authorized_keys file exists\n🔑 Contains {key_count} authorized key(s)", title="[bold green]OK[/bold green]", border_style="green"))
60
+
61
+ try:
62
+ icacls_check = subprocess.run(["icacls", str(authorized_keys)], capture_output=True, text=True, check=False)
63
+ if icacls_check.returncode == 0:
64
+ icacls_output = icacls_check.stdout
65
+ current_user = os.environ.get("USERNAME", "")
66
+ if f"{current_user}:(F)" in icacls_output or f"{current_user}:(M)" in icacls_output:
67
+ console.print(Panel(f"✅ authorized_keys permissions appear correct for user {current_user}", title="[bold green]OK[/bold green]", border_style="green"))
68
+ else:
69
+ console.print(Panel(f"⚠️ authorized_keys permissions may need adjustment\n💡 Run: icacls %USERPROFILE%\\.ssh\\authorized_keys /inheritance:r /grant \"{current_user}:F\"", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
70
+ except Exception:
71
+ pass
72
+ except Exception as read_error:
73
+ results["authorized_keys"] = {"status": "warning", "message": f"Could not read authorized_keys: {str(read_error)}", "action": "Check file encoding and permissions"}
74
+ console.print(Panel(f"⚠️ Could not read authorized_keys: {str(read_error)}", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
75
+
76
+ console.print(Panel("🔧 Checking SSH service status...", title="[bold blue]Service Status[/bold blue]", border_style="blue"))
77
+
78
+ try:
79
+ ssh_service_check = subprocess.run(["powershell", "-Command", "Get-Service -Name sshd -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Status"], capture_output=True, text=True, check=False)
80
+
81
+ if ssh_service_check.returncode == 0 and ssh_service_check.stdout.strip():
82
+ service_status = ssh_service_check.stdout.strip()
83
+ if service_status == "Running":
84
+ results["ssh_service"] = {"status": "ok", "message": "SSH service (sshd) is running", "action": ""}
85
+ console.print(Panel("✅ SSH service (sshd) is running", title="[bold green]OK[/bold green]", border_style="green"))
86
+
87
+ startup_type_check = subprocess.run(["powershell", "-Command", "Get-Service -Name sshd | Select-Object -ExpandProperty StartType"], capture_output=True, text=True, check=False)
88
+ if startup_type_check.returncode == 0:
89
+ startup_type = startup_type_check.stdout.strip()
90
+ if startup_type != "Automatic":
91
+ console.print(Panel(f"ℹ️ SSH service startup type: {startup_type}\n💡 To start automatically: Set-Service -Name sshd -StartupType Automatic", title="[bold blue]Info[/bold blue]", border_style="blue"))
92
+ else:
93
+ results["ssh_service"] = {"status": "error", "message": f"SSH service is {service_status}", "action": "Start with: Start-Service sshd"}
94
+ issues_found.append(f"SSH service {service_status}")
95
+ console.print(Panel(f"❌ SSH service is {service_status}\n💡 Start: Start-Service sshd\n💡 Enable on boot: Set-Service -Name sshd -StartupType Automatic", title="[bold red]Critical Issue[/bold red]", border_style="red"))
96
+ else:
97
+ results["ssh_service"] = {"status": "error", "message": "SSH service (sshd) not found", "action": "Install OpenSSH Server: Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0"}
98
+ issues_found.append("SSH service not installed")
99
+ console.print(Panel("❌ SSH service (sshd) not found\n💡 Install: Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0\n💡 Then start: Start-Service sshd", title="[bold red]Critical Issue[/bold red]", border_style="red"))
100
+ except Exception as service_error:
101
+ results["ssh_service"] = {"status": "warning", "message": f"Could not check service status: {str(service_error)}", "action": "Check SSH service manually"}
102
+ console.print(Panel(f"⚠️ Could not check SSH service status: {str(service_error)}\n💡 Check manually: Get-Service sshd", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
103
+
104
+ console.print(Panel("🌐 Checking network interfaces and IP addresses...", title="[bold blue]Network Interfaces[/bold blue]", border_style="blue"))
105
+
106
+ try:
107
+ ip_addr_check = subprocess.run(["powershell", "-Command", "Get-NetIPAddress -AddressFamily IPv4 -PrefixOrigin Dhcp,Manual | Where-Object {$_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.254.*'} | Select-Object -ExpandProperty IPAddress"], capture_output=True, text=True, check=False)
108
+ if ip_addr_check.returncode == 0 and ip_addr_check.stdout.strip():
109
+ ip_addresses = [ip.strip() for ip in ip_addr_check.stdout.strip().split("\n") if ip.strip()]
110
+
111
+ if ip_addresses:
112
+ results["network_interfaces"] = {"status": "ok", "message": f"Found {len(ip_addresses)} network interface(s)", "action": ""}
113
+ console.print(Panel("✅ Network interfaces found:\n" + "\n".join([f" • {ip}" for ip in ip_addresses]), title="[bold green]IP Addresses[/bold green]", border_style="green"))
114
+ else:
115
+ results["network_interfaces"] = {"status": "warning", "message": "No global IP addresses found", "action": "Check network configuration"}
116
+ issues_found.append("No network IP addresses")
117
+ console.print(Panel("⚠️ No global IP addresses found\n💡 This machine may not be reachable on the network\n💡 Check: Get-NetIPAddress", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
118
+ else:
119
+ results["network_interfaces"] = {"status": "warning", "message": "Could not retrieve IP addresses", "action": "Check network manually"}
120
+ console.print(Panel("⚠️ Could not retrieve IP addresses\n💡 Check: ipconfig", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
121
+ except Exception:
122
+ results["network_interfaces"] = {"status": "warning", "message": "Could not check network interfaces", "action": "Check network manually"}
123
+ console.print(Panel("⚠️ Could not check network interfaces\n💡 Try: ipconfig", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
124
+
125
+ console.print(Panel("🔌 Checking SSH port and listening status...", title="[bold blue]Network Status[/bold blue]", border_style="blue"))
126
+
127
+ sshd_config_paths = [PathExtended("C:\\ProgramData\\ssh\\sshd_config"), PathExtended(os.environ.get("PROGRAMDATA", "C:\\ProgramData")).joinpath("ssh", "sshd_config")]
128
+ sshd_config = None
129
+ for config_path in sshd_config_paths:
130
+ if config_path.exists():
131
+ sshd_config = config_path
132
+ break
133
+
134
+ ssh_port = "22"
135
+ if sshd_config:
136
+ try:
137
+ config_text = sshd_config.read_text(encoding="utf-8")
138
+ port_lines = [line for line in config_text.split("\n") if line.strip().startswith("Port") and not line.strip().startswith("#")]
139
+ if port_lines:
140
+ ssh_port = port_lines[0].split()[1]
141
+
142
+ results["sshd_config"] = {"status": "ok", "message": f"SSH configured to listen on port {ssh_port}", "action": ""}
143
+ console.print(Panel(f"✅ SSH configured to listen on port {ssh_port}", title="[bold green]Config[/bold green]", border_style="green"))
144
+
145
+ password_auth_lines = [line for line in config_text.split("\n") if "PasswordAuthentication" in line and not line.strip().startswith("#")]
146
+ if password_auth_lines:
147
+ password_auth_enabled = "yes" in password_auth_lines[-1].lower()
148
+ if not password_auth_enabled:
149
+ console.print(Panel("ℹ️ Password authentication is disabled\n💡 Only SSH keys will work", title="[bold blue]Info[/bold blue]", border_style="blue"))
150
+
151
+ pubkey_auth_lines = [line for line in config_text.split("\n") if "PubkeyAuthentication" in line and not line.strip().startswith("#")]
152
+ if pubkey_auth_lines:
153
+ pubkey_auth_enabled = "yes" in pubkey_auth_lines[-1].lower()
154
+ if not pubkey_auth_enabled:
155
+ results["pubkey_auth"] = {"status": "error", "message": "PubkeyAuthentication is disabled in sshd_config", "action": "Enable with: PubkeyAuthentication yes in sshd_config"}
156
+ issues_found.append("PubkeyAuthentication disabled")
157
+ console.print(Panel(f"❌ PubkeyAuthentication is DISABLED\n💡 Edit {sshd_config} and set: PubkeyAuthentication yes\n💡 Then restart: Restart-Service sshd", title="[bold red]Critical Issue[/bold red]", border_style="red"))
158
+ else:
159
+ results["pubkey_auth"] = {"status": "ok", "message": "PubkeyAuthentication is enabled", "action": ""}
160
+ console.print(Panel("✅ PubkeyAuthentication is enabled", title="[bold green]OK[/bold green]", border_style="green"))
161
+
162
+ authorized_keys_file_lines = [line for line in config_text.split("\n") if "AuthorizedKeysFile" in line and not line.strip().startswith("#")]
163
+ if authorized_keys_file_lines:
164
+ auth_keys_path = authorized_keys_file_lines[-1].split(None, 1)[1] if len(authorized_keys_file_lines[-1].split(None, 1)) > 1 else ".ssh/authorized_keys"
165
+ console.print(Panel(f"ℹ️ AuthorizedKeysFile: {auth_keys_path}", title="[bold blue]Info[/bold blue]", border_style="blue"))
166
+
167
+ admin_authorized_keys_lines = [line for line in config_text.split("\n") if "Match Group administrators" in line or "AuthorizedKeysFile __PROGRAMDATA__" in line]
168
+ if admin_authorized_keys_lines:
169
+ console.print(Panel("⚠️ IMPORTANT: Administrators group uses different authorized_keys location\n💡 For admin users, keys should be in: C:\\ProgramData\\ssh\\administrators_authorized_keys\n💡 Not in user's .ssh/authorized_keys!", title="[bold yellow]Admin Users[/bold yellow]", border_style="yellow"))
170
+
171
+ programdata_auth_keys = PathExtended(os.environ.get("PROGRAMDATA", "C:\\ProgramData")).joinpath("ssh", "administrators_authorized_keys")
172
+ if programdata_auth_keys.exists():
173
+ console.print(Panel("✅ administrators_authorized_keys file exists", title="[bold green]OK[/bold green]", border_style="green"))
174
+ else:
175
+ results["admin_authorized_keys"] = {"status": "warning", "message": "administrators_authorized_keys not found for admin users", "action": "Create C:\\ProgramData\\ssh\\administrators_authorized_keys"}
176
+ console.print(Panel("⚠️ administrators_authorized_keys not found\n💡 Create: C:\\ProgramData\\ssh\\administrators_authorized_keys\n💡 Set permissions: icacls C:\\ProgramData\\ssh\\administrators_authorized_keys /inheritance:r /grant SYSTEM:F /grant Administrators:F", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
177
+ except Exception as config_error:
178
+ results["sshd_config"] = {"status": "warning", "message": f"Could not read sshd_config: {str(config_error)}", "action": "Check SSH configuration manually"}
179
+ console.print(Panel(f"⚠️ Could not read sshd_config: {str(config_error)}", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
180
+ else:
181
+ results["sshd_config"] = {"status": "warning", "message": "sshd_config not found", "action": "Check SSH configuration manually"}
182
+ console.print(Panel("⚠️ sshd_config not found\n💡 Check if OpenSSH Server is installed\n💡 Expected location: C:\\ProgramData\\ssh\\sshd_config", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
183
+
184
+ try:
185
+ netstat_check = subprocess.run(["netstat", "-an"], capture_output=True, text=True, check=False)
186
+ if netstat_check.returncode == 0:
187
+ netstat_output = netstat_check.stdout
188
+ if f":{ssh_port}" in netstat_output and "LISTENING" in netstat_output:
189
+ ssh_lines = [line for line in netstat_output.split("\n") if f":{ssh_port}" in line and "LISTENING" in line]
190
+ listening_on_all = any("0.0.0.0" in line or "[::]" in line for line in ssh_lines)
191
+ listening_on_localhost_only = all("127.0.0.1" in line or "[::1]" in line for line in ssh_lines)
192
+
193
+ if listening_on_localhost_only:
194
+ results["ssh_listening"] = {"status": "error", "message": f"SSH is listening ONLY on localhost (127.0.0.1:{ssh_port}), not accessible from network", "action": f"Edit {sshd_config}, check ListenAddress, restart SSH"}
195
+ issues_found.append("SSH listening only on localhost")
196
+ console.print(Panel(f"❌ SSH is listening ONLY on localhost (127.0.0.1:{ssh_port})\n💡 This prevents external connections!\n💡 Check sshd_config for 'ListenAddress'\n💡 Remove or comment out 'ListenAddress 127.0.0.1'\n💡 Or change to 'ListenAddress 0.0.0.0'\n💡 Then: Restart-Service sshd", title="[bold red]Critical Issue[/bold red]", border_style="red"))
197
+ elif listening_on_all:
198
+ results["ssh_listening"] = {"status": "ok", "message": f"SSH is listening on all interfaces (0.0.0.0:{ssh_port})", "action": ""}
199
+ console.print(Panel(f"✅ SSH is listening on all interfaces (0.0.0.0:{ssh_port})\n✅ Should be accessible from network", title="[bold green]OK[/bold green]", border_style="green"))
200
+ else:
201
+ results["ssh_listening"] = {"status": "ok", "message": f"SSH is listening on port {ssh_port}", "action": ""}
202
+ console.print(Panel(f"✅ SSH is listening on port {ssh_port}\n\nListening on:\n" + "\n".join([f" {line.strip()}" for line in ssh_lines[:3]]), title="[bold green]OK[/bold green]", border_style="green"))
203
+ else:
204
+ results["ssh_listening"] = {"status": "error", "message": f"SSH is NOT listening on port {ssh_port}", "action": "Check if SSH service is running and configured correctly"}
205
+ issues_found.append(f"SSH not listening on port {ssh_port}")
206
+ console.print(Panel(f"❌ SSH is NOT listening on port {ssh_port}\n💡 Check: netstat -an | findstr :{ssh_port}\n💡 Restart: Restart-Service sshd", title="[bold red]Critical Issue[/bold red]", border_style="red"))
207
+ else:
208
+ results["ssh_listening"] = {"status": "warning", "message": "Could not check listening status", "action": "Check manually with: netstat -an"}
209
+ console.print(Panel("⚠️ Could not check listening status\n💡 Check manually: netstat -an | findstr :22", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
210
+ except Exception:
211
+ results["ssh_listening"] = {"status": "warning", "message": "Could not check listening status", "action": "Check manually"}
212
+ console.print(Panel("⚠️ Could not check listening status\n💡 Try: netstat -an | findstr :22", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
213
+
214
+ console.print(Panel("🧱 Checking Windows Firewall status...", title="[bold blue]Firewall[/bold blue]", border_style="blue"))
215
+
216
+ try:
217
+ firewall_check = subprocess.run(["powershell", "-Command", "Get-NetFirewallRule -DisplayName '*SSH*' | Select-Object DisplayName, Enabled, Direction, Action"], capture_output=True, text=True, check=False)
218
+ if firewall_check.returncode == 0 and firewall_check.stdout.strip():
219
+ firewall_output = firewall_check.stdout
220
+ ssh_rules_enabled = "True" in firewall_output and "Allow" in firewall_output
221
+
222
+ if ssh_rules_enabled:
223
+ results["firewall"] = {"status": "ok", "message": "Windows Firewall has SSH rules enabled", "action": ""}
224
+ console.print(Panel("✅ Windows Firewall has SSH rules enabled\n\n" + firewall_output[:300], title="[bold green]OK[/bold green]", border_style="green"))
225
+ else:
226
+ results["firewall"] = {"status": "error", "message": "Windows Firewall may be blocking SSH", "action": "Add firewall rule: New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22"}
227
+ issues_found.append("Firewall blocking SSH")
228
+ console.print(Panel("❌ Windows Firewall may be blocking SSH\n💡 Add rule: New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22", title="[bold red]Critical Issue[/bold red]", border_style="red"))
229
+ else:
230
+ firewall_status_check = subprocess.run(["powershell", "-Command", "Get-NetFirewallProfile | Select-Object Name, Enabled"], capture_output=True, text=True, check=False)
231
+ if firewall_status_check.returncode == 0:
232
+ console.print(Panel("⚠️ No SSH-specific firewall rules found\n💡 Add rule: New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
233
+ except Exception:
234
+ results["firewall"] = {"status": "warning", "message": "Could not check firewall status", "action": "Check manually"}
235
+ console.print(Panel("⚠️ Could not check Windows Firewall\n💡 Check manually: Get-NetFirewallRule -DisplayName '*SSH*'", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
236
+
237
+ console.print(Panel("👥 Checking user account and admin status...", title="[bold blue]User Account[/bold blue]", border_style="blue"))
238
+
239
+ try:
240
+ current_user = os.environ.get("USERNAME", "unknown")
241
+ admin_check = subprocess.run(["powershell", "-Command", "([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)"], capture_output=True, text=True, check=False)
242
+
243
+ is_admin = "True" in admin_check.stdout if admin_check.returncode == 0 else False
244
+
245
+ if is_admin:
246
+ results["user_account"] = {"status": "warning", "message": f"Current user ({current_user}) is an Administrator", "action": "Check administrators_authorized_keys location"}
247
+ console.print(Panel(f"⚠️ Current user ({current_user}) is an Administrator\n💡 Admin users may need keys in: C:\\ProgramData\\ssh\\administrators_authorized_keys\n💡 Not in %USERPROFILE%\\.ssh\\authorized_keys", title="[bold yellow]Important[/bold yellow]", border_style="yellow"))
248
+ else:
249
+ results["user_account"] = {"status": "ok", "message": f"Current user ({current_user}) is a standard user", "action": ""}
250
+ console.print(Panel(f"✅ Current user ({current_user}) is a standard user\n💡 Keys should be in: %USERPROFILE%\\.ssh\\authorized_keys", title="[bold green]OK[/bold green]", border_style="green"))
251
+ except Exception:
252
+ results["user_account"] = {"status": "warning", "message": "Could not check user account status", "action": ""}
253
+ console.print(Panel("⚠️ Could not check user account status", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
254
+
255
+ console.print(Panel("📋 Checking SSH logs for errors...", title="[bold blue]Logs[/bold blue]", border_style="blue"))
256
+
257
+ try:
258
+ log_check = subprocess.run(["powershell", "-Command", "Get-WinEvent -LogName 'OpenSSH/Admin' -MaxEvents 20 -ErrorAction SilentlyContinue | Where-Object {$_.LevelDisplayName -eq 'Error' -or $_.LevelDisplayName -eq 'Warning'} | Select-Object TimeCreated, LevelDisplayName, Message | Format-List"], capture_output=True, text=True, check=False)
259
+
260
+ if log_check.returncode == 0 and log_check.stdout.strip():
261
+ log_output = log_check.stdout
262
+ results["ssh_logs"] = {"status": "warning", "message": "Found SSH errors/warnings in event log", "action": "Review event log"}
263
+ console.print(Panel(f"⚠️ Found SSH errors/warnings:\n\n{log_output[:500]}", title="[bold yellow]Log Errors[/bold yellow]", border_style="yellow"))
264
+ else:
265
+ results["ssh_logs"] = {"status": "ok", "message": "No recent SSH errors in event log", "action": ""}
266
+ console.print(Panel("✅ No recent SSH errors in event log", title="[bold green]OK[/bold green]", border_style="green"))
267
+ except Exception:
268
+ results["ssh_logs"] = {"status": "warning", "message": "Could not check SSH logs", "action": "Check manually: Get-WinEvent -LogName 'OpenSSH/Admin'"}
269
+ console.print(Panel("⚠️ Could not check SSH logs\n💡 Check: Get-WinEvent -LogName 'OpenSSH/Admin' -MaxEvents 20", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
270
+
271
+ console.print(Panel("🧪 Testing local SSH connection...", title="[bold blue]Connection Test[/bold blue]", border_style="blue"))
272
+
273
+ try:
274
+ local_user = os.environ.get("USERNAME", "unknown")
275
+ ssh_test = subprocess.run(["ssh", "-o", "ConnectTimeout=5", "-o", "StrictHostKeyChecking=no", "-o", "BatchMode=yes", f"{local_user}@localhost", "echo", "test"], capture_output=True, text=True, check=False, timeout=10)
276
+
277
+ if ssh_test.returncode == 0:
278
+ results["local_ssh_test"] = {"status": "ok", "message": "Local SSH connection successful", "action": ""}
279
+ console.print(Panel("✅ Local SSH connection works\n✅ SSH server is functional", title="[bold green]OK[/bold green]", border_style="green"))
280
+ else:
281
+ error_output = ssh_test.stderr
282
+ results["local_ssh_test"] = {"status": "warning", "message": f"Local SSH test failed: {error_output[:100]}", "action": "Check SSH keys and configuration"}
283
+ console.print(Panel(f"⚠️ Local SSH test failed\n💡 Error: {error_output[:200]}\n💡 This may be normal if key authentication is not set up for localhost", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
284
+ except subprocess.TimeoutExpired:
285
+ results["local_ssh_test"] = {"status": "error", "message": "Local SSH connection timed out", "action": "SSH may be hanging or not responding"}
286
+ issues_found.append("SSH connection timeout")
287
+ console.print(Panel("❌ Local SSH connection timed out\n💡 SSH server may not be responding\n💡 Check: Get-Service sshd", title="[bold red]Critical Issue[/bold red]", border_style="red"))
288
+ except FileNotFoundError:
289
+ results["local_ssh_test"] = {"status": "warning", "message": "ssh client not found", "action": "Install SSH client: Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0"}
290
+ console.print(Panel("⚠️ SSH client not installed\n💡 Install: Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
291
+ except Exception as test_error:
292
+ results["local_ssh_test"] = {"status": "warning", "message": f"Could not test SSH: {str(test_error)}", "action": ""}
293
+ console.print(Panel(f"⚠️ Could not test SSH connection: {str(test_error)}", title="[bold yellow]Warning[/bold yellow]", border_style="yellow"))
294
+
295
+ console.print(Panel("📊 DIAGNOSTIC SUMMARY", box=box.DOUBLE_EDGE, title_align="left"))
296
+
297
+ if issues_found:
298
+ console.print(Panel(f"⚠️ Found {len(issues_found)} issue(s):\n\n" + "\n".join([f"• {issue}" for issue in issues_found]), title="[bold yellow]Issues Found[/bold yellow]", border_style="yellow"))
299
+ else:
300
+ console.print(Panel("✅ No critical issues detected\n\nIf you still cannot connect:\n• Check client-side configuration\n• Verify network connectivity\n• Ensure correct username and hostname\n• Check if public key is correctly added to authorized_keys\n• For admin users, check C:\\ProgramData\\ssh\\administrators_authorized_keys", title="[bold green]All Checks Passed[/bold green]", border_style="green"))
301
+
302
+ console.print(Panel("🔗 CONNECTION INFORMATION", box=box.DOUBLE_EDGE, title_align="left"))
303
+
304
+ try:
305
+ current_user = os.environ.get("USERNAME", "unknown")
306
+ hostname_result = subprocess.run(["hostname"], capture_output=True, text=True, check=False)
307
+ hostname = hostname_result.stdout.strip() if hostname_result.returncode == 0 else "unknown"
308
+
309
+ ip_addr_result = subprocess.run(["powershell", "-Command", "Get-NetIPAddress -AddressFamily IPv4 -PrefixOrigin Dhcp,Manual | Where-Object {$_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.254.*'} | Select-Object -ExpandProperty IPAddress"], capture_output=True, text=True, check=False)
310
+ connection_ips: list[str] = []
311
+ if ip_addr_result.returncode == 0 and ip_addr_result.stdout.strip():
312
+ connection_ips = [ip.strip() for ip in ip_addr_result.stdout.strip().split("\n") if ip.strip()]
313
+
314
+ connection_info = f"👤 Username: {current_user}\n🖥️ Hostname: {hostname}\n🔌 SSH Port: {ssh_port}\n"
315
+
316
+ if connection_ips:
317
+ connection_info += "\n🌐 This machine can be accessed via SSH from other machines on the same network using:\n\n"
318
+ for ip in connection_ips:
319
+ connection_info += f" ssh {current_user}@{ip}\n"
320
+ if ssh_port != "22":
321
+ connection_info += f"\n (Port {ssh_port} should be used: ssh -p {ssh_port} {current_user}@<IP>)\n"
322
+ else:
323
+ connection_info += "\n⚠️ No network IP addresses found - this machine may not be reachable from the network"
324
+
325
+ connection_info += "\n\n💡 From another machine on the same network, use one of the commands above"
326
+ connection_info += "\n💡 Ensure your public key is in the correct authorized_keys location"
327
+ connection_info += "\n💡 For admin users: C:\\ProgramData\\ssh\\administrators_authorized_keys"
328
+ connection_info += "\n💡 For standard users: %USERPROFILE%\\.ssh\\authorized_keys"
329
+
330
+ console.print(Panel(connection_info, title="[bold cyan]SSH Connection Details[/bold cyan]", border_style="cyan"))
331
+ except Exception as conn_error:
332
+ console.print(Panel(f"⚠️ Could not gather connection information: {str(conn_error)}", title="[bold yellow]Connection Info[/bold yellow]", border_style="yellow"))
333
+
334
+ return results
335
+
336
+
337
+ if __name__ == "__main__":
338
+ ssh_debug_windows()
@@ -154,7 +154,7 @@ def git_action(path: PathExtended, action: GitAction, mess: Optional[str] = None
154
154
  elif action == GitAction.pull:
155
155
  # Use the enhanced update function with uv sync support
156
156
  try:
157
- update_repository(repo, auto_sync=auto_sync, allow_password_prompt=False)
157
+ update_repository(repo, auto_uv_sync=auto_sync, allow_password_prompt=False)
158
158
  print("✅ Pull completed")
159
159
  return GitOperationResult(
160
160
  repo_path=path,
@@ -310,7 +310,7 @@ def print_git_operations_summary(summary: GitOperationSummary, operations_perfor
310
310
  console.print(f"\n[bold green]⚖️ SUMMARY: {total_operations}/{total_operations} operations succeeded (100% success rate)[/bold green]")
311
311
 
312
312
 
313
- def perform_git_operations(repos_root: PathExtended, pull: bool, commit: bool, push: bool, recursive: bool, auto_sync: bool) -> None:
313
+ def perform_git_operations(repos_root: PathExtended, pull: bool, commit: bool, push: bool, recursive: bool, auto_uv_sync: bool) -> None:
314
314
  """Perform git operations on all repositories and provide detailed summary."""
315
315
  print(f"\n🔄 Performing Git actions on repositories @ `{repos_root}`...")
316
316
  summary = GitOperationSummary()
@@ -341,7 +341,7 @@ def perform_git_operations(repos_root: PathExtended, pull: bool, commit: bool, p
341
341
 
342
342
  # Now perform the actual operations
343
343
  if pull:
344
- result = git_action(path=a_path, action=GitAction.pull, r=recursive, auto_sync=auto_sync)
344
+ result = git_action(path=a_path, action=GitAction.pull, r=recursive, auto_sync=auto_uv_sync)
345
345
  summary.pulls_attempted += 1
346
346
  if result.success:
347
347
  summary.pulls_successful += 1
@@ -350,7 +350,7 @@ def perform_git_operations(repos_root: PathExtended, pull: bool, commit: bool, p
350
350
  summary.failed_operations.append(result)
351
351
 
352
352
  if commit:
353
- result = git_action(a_path, action=GitAction.commit, r=recursive, auto_sync=auto_sync)
353
+ result = git_action(a_path, action=GitAction.commit, r=recursive, auto_sync=auto_uv_sync)
354
354
  summary.commits_attempted += 1
355
355
  if result.success:
356
356
  if result.had_changes:
@@ -362,7 +362,7 @@ def perform_git_operations(repos_root: PathExtended, pull: bool, commit: bool, p
362
362
  summary.failed_operations.append(result)
363
363
 
364
364
  if push:
365
- result = git_action(a_path, action=GitAction.push, r=recursive, auto_sync=auto_sync)
365
+ result = git_action(a_path, action=GitAction.push, r=recursive, auto_sync=auto_uv_sync)
366
366
  summary.pushes_attempted += 1
367
367
  if result.success:
368
368
  summary.pushes_successful += 1
@@ -24,7 +24,7 @@ def git_operations(
24
24
  ) -> None:
25
25
 
26
26
  repos_root = resolve_directory(directory)
27
- auto_sync = not no_sync
27
+ auto_uv_sync = not no_sync
28
28
  from machineconfig.scripts.python.repos_helpers.action import perform_git_operations
29
29
  from machineconfig.utils.path_extended import PathExtended
30
30
  perform_git_operations(
@@ -33,7 +33,7 @@ def git_operations(
33
33
  commit=commit,
34
34
  push=push,
35
35
  recursive=recursive,
36
- auto_sync=auto_sync,
36
+ auto_uv_sync=auto_uv_sync,
37
37
  )
38
38
  def resolve_spec_path(directory: Optional[str], cloud: Optional[str]) -> Path:
39
39
  repos_root = resolve_directory(directory)
@@ -65,7 +65,7 @@ def get_file_hash(file_path: Path) -> str | None:
65
65
  return hashlib.sha256(file_path.read_bytes()).hexdigest()
66
66
 
67
67
 
68
- def update_repository(repo: git.Repo, auto_sync: bool, allow_password_prompt: bool) -> RepositoryUpdateResult:
68
+ def update_repository(repo: git.Repo, auto_uv_sync: bool, allow_password_prompt: bool) -> RepositoryUpdateResult:
69
69
  """Update a single repository and return detailed information about what happened."""
70
70
  repo_path = Path(repo.working_dir)
71
71
  print(f"🔄 {'Updating ' + str(repo_path):.^80}")
@@ -253,7 +253,7 @@ def update_repository(repo: git.Repo, auto_sync: bool, allow_password_prompt: bo
253
253
  print(f"✅ Set permissions for {lf_exe_path}")
254
254
 
255
255
  # Run uv sync if dependencies changed and auto_sync is enabled
256
- if result["dependencies_changed"] and auto_sync:
256
+ if result["dependencies_changed"] and auto_uv_sync:
257
257
  result["uv_sync_ran"] = True
258
258
  result["uv_sync_success"] = run_uv_sync(repo_path)
259
259