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

Hooks still not working on MacOS #685

Open
robinbowes opened this issue Aug 7, 2024 · 0 comments
Open

Hooks still not working on MacOS #685

robinbowes opened this issue Aug 7, 2024 · 0 comments

Comments

@robinbowes
Copy link

After around 6 years, I've returned to a role where I'm using ssh, and need to integrate my assh config with some native ssh config that is generated by internal tooling.

However, I'm still seeing exactly the same as #262 , which was closed as fixed in #297, ie. the hooks are not firing, specifically the AfterConfigWrite hook is not appending ssh config to the generate config file.

This is my test assh.yml:

defaults:
  # Defaults are applied to each hosts
  ControlMaster: auto
  # ControlMasterMkdir: true
  ControlPath: ~/tmp/.ssh/cm/%h-%p-%r.sock
  ControlPersist: yes
  Hooks:
    AfterConfigWrite:
      - "exec echo {{.SSHConfigPath}}"
      - "exec cat ~/.ssh/extra.config >> {{.SSHConfigPath}}"
  IdentityFile:
    - ~/.ssh/id_rsa
  LogLevel: ERROR
  Port: 22

I run assh with this command-line:

assh -D wrapper ssh -- truenas

This is the output:

2024-08-07T01:26:08.435+0100	DEBUG	assh.pkg.commands	commands/wrapper.go:51	Skip invalid option:	{"flag": "O", "val": "false"}
2024-08-07T01:26:08.435+0100	DEBUG	assh.pkg.commands	commands/wrapper.go:51	Skip invalid option:	{"flag": "o", "val": "false"}
2024-08-07T01:26:08.435+0100	DEBUG	assh.pkg.commands	commands/wrapper.go:71	Wrapper called	{"bin": "/opt/homebrew/bin/ssh", "target": "truenas", "command": [], "options": [], "sshArgs": ["ssh", "truenas"]}
2024-08-07T01:26:08.435+0100	DEBUG	assh.pkg.config	config/config.go:516	Loading config file	{"file": "/Users/robin/.ssh/assh.yml"}
2024-08-07T01:26:08.435+0100	DEBUG	assh.pkg.config	config/config.go:534	Loaded config file	{"file": "/Users/robin/.ssh/assh.yml", "num-host-before": 0, "num-host-after": 0, "num-host-diff": 0}
2024-08-07T01:26:08.435+0100	DEBUG	assh.pkg.commands	commands/wrapper.go:87	Failed to load assh known_hosts	{"error": "open /Users/robin/.ssh/assh_known_hosts: no such file or directory"}
2024-08-07T01:26:08.435+0100	DEBUG	assh.pkg.commands	commands/wrapper.go:96	The configuration file is outdated, rebuilding it before calling command	{"command": "ssh"}
2024-08-07T01:26:08.435+0100	DEBUG	assh.pkg.config	config/config.go:469	Writing SSH config file	{"file": "/Users/robin/.ssh/config"}
2024-08-07T01:26:08.435+0100	DEBUG	assh.pkg.config	config/config.go:482	Unable to remove tempfile	{"file": "/Users/robin/.ssh/config2436378249"}

The generated config file looks like this:

# This file was automatically generated by assh vn/a (n/a)
# on 2024-08-07 01:26:08 +0100 BST, based on ~/.ssh/assh.yml
#
# more info: https://github.com/moul/assh

# host-based configuration
# global configuration
Host *
  ControlMaster auto
  ControlPath ~/tmp/.ssh/cm/%h-%p-%r.sock
  ControlPersist yes
  IdentityFile ~/.ssh/id_rsa
  LogLevel ERROR
  Port 22
  ProxyCommand /opt/homebrew/bin/assh connect --port=%p %h
  # Hooks: {"AfterConfigWrite":["exec echo {{.SSHConfigPath}}","exec cat ~/.ssh/extra.config \u003e\u003e {{.SSHConfigPath}}"]}

Am I doing something wrong, or is this still broken?

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

1 participant