Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "nexusai"
version = "0.5.28"
version = "0.5.29"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.9"
Expand Down
1 change: 1 addition & 0 deletions src/nexus/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TargetConfig(pyd.BaseModel):
host: str
port: int = pyd.Field(default=54323)
ssh_user: str
ssh_port: int = pyd.Field(default=22)


REQUIRED_ENV_VARS = {
Expand Down
14 changes: 9 additions & 5 deletions src/nexus/cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,16 @@ def open_jobrc_editor() -> None:
utils.open_file_in_editor(jobrc_path)


def _test_ssh_connection(host: str, ssh_user: str) -> bool:
def _test_ssh_connection(host: str, ssh_user: str, ssh_port: int = 22) -> bool:
import subprocess

print(colored("\nTesting SSH connection...", "cyan"))
try:
result = subprocess.run(
[
"ssh",
"-p",
str(ssh_port),
"-o",
"ConnectTimeout=10",
"-o",
Expand Down Expand Up @@ -397,19 +399,21 @@ def add_target() -> None:
return

host = utils.get_user_input("Remote server address (hostname or IP)", required=True)
port = int(utils.get_user_input("Remote server port", default="54323"))
ssh_port = int(utils.get_user_input("SSH port", default="22"))
ssh_user = utils.get_user_input("SSH username", default=os.environ.get("USER", ""))
port = int(utils.get_user_input("Remote server port", default="54323"))

print(colored("\nValidating connection...", "cyan", attrs=["bold"]))

if not _test_ssh_connection(host, ssh_user):
if not _test_ssh_connection(host, ssh_user, ssh_port):
print(colored("\n✗ SSH connection failed", "red"))
print(colored("\nTo fix:", "yellow"))
print(colored(f" 1. Ensure your SSH key is in ~/.ssh/authorized_keys on {host}", "yellow"))
print(colored(f" 2. Test manually: ssh {ssh_user}@{host} echo ok", "yellow"))
port_flag = f"-p {ssh_port} " if ssh_port != 22 else ""
print(colored(f" 2. Test manually: ssh {port_flag}{ssh_user}@{host} echo ok", "yellow"))
return

target_cfg = config.TargetConfig(host=host, port=port, ssh_user=ssh_user)
target_cfg = config.TargetConfig(host=host, port=port, ssh_user=ssh_user, ssh_port=ssh_port)
cfg.targets[target_name] = target_cfg
config.save_config(cfg)

Expand Down
5 changes: 4 additions & 1 deletion src/nexus/cli/tunnel_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def _start_control_master(target_name: str, target_cfg: config.TargetConfig) ->
"-S",
str(socket_path),
"-fN",
"-p",
str(target_cfg.ssh_port),
"-L",
f"{local_port}:127.0.0.1:{target_cfg.port}",
"-o",
Expand Down Expand Up @@ -184,10 +186,11 @@ def _start_control_master(target_name: str, target_cfg: config.TargetConfig) ->
time.sleep(0.1)
last_error = SSHTunnelError(f"Port {local_port} already in use, retrying...")
continue
port_flag = f"-p {target_cfg.ssh_port}" if target_cfg.ssh_port != 22 else ""
raise SSHTunnelError(
f"Failed to start SSH tunnel\n"
f"Error: {error_msg}\n"
f"Hint: Verify SSH access with: ssh {target_cfg.ssh_user}@{target_cfg.host} echo ok"
f"Hint: Verify SSH access with: ssh {port_flag} {target_cfg.ssh_user}@{target_cfg.host} echo ok".strip()
)

if not _wait_for_tunnel(local_port, timeout=10.0):
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.