the hostname could not be number
dfang opened this issue · 3 comments
dfang commented
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/root@0.0.0.101-22.sock" 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?
maxclac commented
Hi! I am running into the same problem. Has it been solved?