Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the hostname could not be number #674

Open
dfang opened this issue Sep 30, 2023 · 3 comments
Open

the hostname could not be number #674

dfang opened this issue Sep 30, 2023 · 3 comments

Comments

@dfang
Copy link

dfang commented Sep 30, 2023

sample from generated ~/ssh/.config

# This file was automatically generated by assh vn/a (n/a)
# on 2023-09-30 10:28:23 +0800 CST, based on ~/.ssh/assh.yml
#
# more info: https://github.com/moul/assh

# host-based configuration
Host 101
  Port 22
  User root
  # HostName: 192.168.2.101

Host 110
  Port 22
  User deploy
  # HostName: 192.168.2.110

log

λ ssh 101 -vvv
OpenSSH_9.3p1, OpenSSL 1.1.1u  30 May 2023
debug1: Reading configuration data /Users/kb24/.ssh/config
debug1: /Users/kb24/.ssh/config line 7: Applying options for 101
debug1: /Users/kb24/.ssh/config line 130: Applying options for *
debug1: Reading configuration data /usr/local/etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 101 is address
debug2: resolve_canonicalize: canonicalised address "101" => "0.0.0.101"
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/kb24/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/kb24/.ssh/known_hosts2'
debug1: auto-mux: Trying existing master
debug1: Control socket "/Users/kb24/.ssh/sockets/[email protected]" does not exist
debug1: Executing proxy command: exec /Users/kb24/bin/assh connect --port=22 0.0.0.101
debug1: identity file /Users/kb24/.ssh/id_rsa type 0
debug1: identity file /Users/kb24/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.3
DEBUG	initializing proxy	{"target": "0.0.0.101"}
DEBUG	Loading config file	{"file": "/Users/kb24/.ssh/assh.yml"}
DEBUG	Loaded config file	{"file": "/Users/kb24/.ssh/assh.yml", "num-host-before": 0, "num-host-after": 24, "num-host-diff": 24}
DEBUG	Failed to load assh known_hosts	{"error": "open /Users/kb24/.ssh/assh_known_hosts: no such file or directory"}
DEBUG	generated ssh config file	{"buffer": "Host 0.0.0.101\n  ControlMaster auto\n  ControlPath ~/.ssh/sockets/%r@%h-%p.sock\n  ControlPersist 600\n  IdentityFile ~/.ssh/id_rsa\n  Port 22\n  StrictHostKeyChecking no\n  User deploy\n  # HostName: 0.0.0.101\n  # Hooks: {\"AfterConfigWrite\":[\"exec cat ~/.ssh/my-heroku-generated-config \\u003e\\u003e {{.SSHConfigPath}}\",\"notify \\\"{{.SSHConfigPath}} has been rewritten\\\"\"],\"BeforeConfigWrite\":[\"exec set -x; cp {{.SSHConfigPath}} {{.SSHConfigPath}}.bkp\"],\"OnConnect\":[\"exec printf '{{.}}' | jq . \\u003e\\u003e ~/.ssh/last_connected_host.txt\",\"notify New SSH connection to {{.Host.Prototype}} at {{.Stats.ConnectedAt}}\",\"write New SSH connection to {{.Host.Prototype}}\"],\"OnDisconnect\":[\"write  SSH connection to {{.Host.HostName}} closed, {{.Stats.WrittenBytes }} bytes written in {{.Stats.ConnectionDuration}} ({{.Stats.AverageSpeed}}bps)\",\"notify SSH connection to {{.Host.HostName}} closed, {{.Stats.WrittenBytes }} bytes written in {{.Stats.ConnectionDuration}} ({{.Stats.AverageSpeed}}bps)\"]}\n"}
DEBUG	Host	{"host": "{\"ControlMaster\":\"auto\",\"ControlPath\":\"~/.ssh/sockets/%r@%h-%p.sock\",\"ControlPersist\":\"600\",\"IdentityFile\":[\"~/.ssh/id_rsa\"],\"Port\":\"22\",\"StrictHostKeyChecking\":\"no\",\"User\":\"deploy\",\"HostName\":\"0.0.0.101\",\"Hooks\":{\"AfterConfigWrite\":[\"exec cat ~/.ssh/my-heroku-generated-config \\u003e\\u003e {{.SSHConfigPath}}\",\"notify \\\"{{.SSHConfigPath}} has been rewritten\\\"\"],\"BeforeConfigWrite\":[\"exec set -x; cp {{.SSHConfigPath}} {{.SSHConfigPath}}.bkp\"],\"OnConnect\":[\"exec printf '{{.}}' | jq . \\u003e\\u003e ~/.ssh/last_connected_host.txt\",\"notify New SSH connection to {{.Host.Prototype}} at {{.Stats.ConnectedAt}}\",\"write New SSH connection to {{.Host.Prototype}}\"],\"OnDisconnect\":[\"write  SSH connection to {{.Host.HostName}} closed, {{.Stats.WrittenBytes }} bytes written in {{.Stats.ConnectionDuration}} ({{.Stats.AverageSpeed}}bps)\",\"notify SSH connection to {{.Host.HostName}} closed, {{.Stats.WrittenBytes }} bytes written in {{.Stats.ConnectionDuration}} ({{.Stats.AverageSpeed}}bps)\"]}}"}
DEBUG	Proxying
DEBUG	Connecting without gateway
DEBUG	Preparing host object
DEBUG	Calling BeforeConnect hooks
DEBUG	Connecting to host	{"hostname": "0.0.0.101", "port": "22"}
DEBUG	Calling OnConnectError hooks
Error: failed to dial: dial tcp 0.0.0.101:22: connect: no route to host
Usage:
  assh connect [flags]

Examples:
Argument is a host.

Flags:
      --dry-run      Only show how assh would connect but don't actually do it
  -h, --help         help for connect
      --no-rewrite   Do not automatically rewrite outdated configuration
  -p, --port int     SSH destination port

failed to dial: dial tcp 0.0.0.101:22: connect: no route to host
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535

why the hostname is # HostName: 192.168.2.101 in generated ~/.ssh/config, not hostname 192.168.2.101, Can I customize the template before building config?

@ghost
Copy link

ghost commented Mar 20, 2024

Hi! I am running into the same problem. Has it been solved?

@uberjay
Copy link

uberjay commented Nov 13, 2024

This just started happening for me, today... Could have been post-homebrew-upgrade, but unfortunately wasn't paying enough attention to notice when it broke.

EDIT: The hostname is supposed to be commented out, i realized -- the actual connection is made using assh connect --port=<port> <host>. Bizarrely, this command is triggering a no route to host error for me, all of a sudden:

$ /usr/local/bin/assh connect --port=22 10.0.10.1
Error: failed to dial: dial tcp 10.0.10.1:22: connect: no route to host
Usage:
  assh connect [flags]

Examples:
Argument is a host.

Flags:
      --dry-run      Only show how assh would connect but don't actually do it
  -h, --help         help for connect
      --no-rewrite   Do not automatically rewrite outdated configuration
  -p, --port int     SSH destination port

failed to dial: dial tcp 10.0.10.1:22: connect: no route to host

ssh (using a config to bypass assh) works fine:

$ /usr/bin/ssh -F plain_ssh 10.0.10.1
SSH@sw-core>

other tools (e.g, netcat) also connect successfully.

I'm running assh 2.16.0, freshly re-installed with brew on macOS 15.1.

Other IP addresses seem to connect fine. This happens to (as far as I can tell) only affect sshing to the IP address which is also the default gateway for my host's primary IP address... 😕

@uberjay
Copy link

uberjay commented Nov 13, 2024

Turns out, in my case, this is golang running afoul of a newer macOS security mechanism.

I guess this will be fixed when a fixed go compiler is used to build assh. (for homebrew)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants