commander icon indicating copy to clipboard operation
commander copied to clipboard

SSH public key authentication broken in commander 2.4.0 on CentOS 8.4.2105

Open stdevel opened this issue 4 years ago • 1 comments

Prerequisites

  • [x] Can you reproduce the problem?
  • [x] Are you running the latest version?
  • [x] Did you perform a cursory search?

Description

When using SSH public key authentication, commander crashes:

# commander test test.yml --verbose
Starting test file test.yml...

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x79ea53]

goroutine 23 [running]:
golang.org/x/crypto/ssh.publicKeyCallback.auth(0xc00030a960, 0xc000024240, 0x20, 0x20, 0x0, 0x0, 0xa80aa0, 0xc00034c000, 0xa76980, 0xc0000721b0, ...)
	/home/travis/gopath/pkg/mod/golang.org/x/[email protected]/ssh/client_auth.go:204 +0xd3
golang.org/x/crypto/ssh.(*connection).clientAuthenticate(0xc000340080, 0xc00033e000, 0x0, 0xa)
	/home/travis/gopath/pkg/mod/golang.org/x/[email protected]/ssh/client_auth.go:44 +0x332
golang.org/x/crypto/ssh.(*connection).clientHandshake(0xc000340080, 0xc0002c8d58, 0x8, 0xc00033e000, 0x0, 0x0)
	/home/travis/gopath/pkg/mod/golang.org/x/[email protected]/ssh/client.go:113 +0x2b6
golang.org/x/crypto/ssh.NewClientConn(0xa865a0, 0xc00000e010, 0xc0002c8d58, 0x8, 0xc000140968, 0xa865a0, 0xc00000e010, 0x0, 0x0, 0xc00030a980, ...)
	/home/travis/gopath/pkg/mod/golang.org/x/[email protected]/ssh/client.go:83 +0xf8
golang.org/x/crypto/ssh.Dial(0x9b9aeb, 0x3, 0xc0002c8d58, 0x8, 0xc000140968, 0xc00030a980, 0x1, 0x2)
	/home/travis/gopath/pkg/mod/golang.org/x/[email protected]/ssh/client.go:177 +0xb3
github.com/commander-cli/commander/pkg/runtime.SSHExecutor.Execute(0xc0002c8d58, 0x8, 0x0, 0x0, 0x0, 0x0, 0xc000308620, 0x15, 0xc0002c8db0, 0xf, ...)
	/home/travis/gopath/src/github.com/commander-cli/commander/pkg/runtime/ssh_executor.go:76 +0x1d0
github.com/commander-cli/commander/pkg/runtime.(*Runner).Run.func2(0xc0002c8f40, 0xc00030a8c0, 0xc00006eae0, 0xc00006ea80)
	/home/travis/gopath/src/github.com/commander-cli/commander/pkg/runtime/runner.go:49 +0x231
created by github.com/commander-cli/commander/pkg/runtime.(*Runner).Run
	/home/travis/gopath/src/github.com/commander-cli/commander/pkg/runtime/runner.go:30 +0x113

Using plain username/password authentication works.

Steps to Reproduce

  1. Create a YML document as seen below
  2. Run commander test test.yml
  3. Watch the beautiful stacktrace :)
nodes:
  node1:
    type: ssh
    addr: node1:22
    identity-file: /root/.ssh/id_rsa.pub
    #user: root
    #pass: trustno1

config:
  nodes:
    - node1

tests:
  check kurt user:
    command: id kurt
    stdout:
      contains:
        - kurt
      not-contains:
        - no such user
    exit-code: 0

Expected behavior: [What you expected to happen]

SSH login succeeds and test is executed.

Actual behavior: [What actually happened]

Application crashes.

Specifications

  • Version: v2.4.0
  • Platform: CentOS Linux 8.4.2105 (x86_64)
  • Subsystem: ?

You can get the version information from executing commander --version.

stdevel avatar Oct 06 '21 08:10 stdevel

Thanks @stdevel for the submission. Looked into it and was able to reproduce it. It will be fixed in #181

SimonBaeumer avatar Nov 19 '21 15:11 SimonBaeumer