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

Getting errors when hit to /prob?pattern="pattern_Name" #1

Closed
manikSMahajan opened this issue Oct 5, 2017 · 4 comments
Closed

Getting errors when hit to /prob?pattern="pattern_Name" #1

manikSMahajan opened this issue Oct 5, 2017 · 4 comments

Comments

@manikSMahajan
Copy link

manikSMahajan commented Oct 5, 2017

OS:Ubuntu 14.04
When i run ssh_exporter and when i click to localhost:9382/probe?pattern="manik", it show this

URL:http://localhost:9382/probe?pattern=manik

Output on terminal
2017/10/05 11:31:48 ssh_exporter :: Listening on localhost:9382
2017/10/05 11:31:52 ssh_exporter :: ssh: cannot decode encrypted private keys
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x50c763]

goroutine 24 [running]:
panic(0x72ecc0, 0xc42000c120)
	/usr/local/go/src/runtime/panic.go:500 +0x1a1
golang.org/x/crypto/ssh.publicKeyCallback.auth(0xc420112e20, 0xc420113260, 0x20, 0x20, 0xc4201201b0, 0x4, 0x90ca80, 0xc42009b1e0, 0x907b40, 0xc4200781e0, ...)
	/usr/local/go/bin/src/golang.org/x/crypto/ssh/client_auth.go:193 +0xb3
golang.org/x/crypto/ssh.(*connection).clientAuthenticate(0xc420098c80, 0xc4200f8180, 0x0, 0xa)
	/usr/local/go/bin/src/golang.org/x/crypto/ssh/client_auth.go:36 +0x353
golang.org/x/crypto/ssh.(*connection).clientHandshake(0xc420098c80, 0xc420120700, 0xc, 0xc4200f8180, 0x0, 0x0)
	/usr/local/go/bin/src/golang.org/x/crypto/ssh/client.go:112 +0x2ed
golang.org/x/crypto/ssh.NewClientConn(0x90f480, 0xc420088120, 0xc420120700, 0xc, 0xc42004dd00, 0x90f480, 0xc420088120, 0x0, 0x0, 0xc420120700, ...)
	/usr/local/go/bin/src/golang.org/x/crypto/ssh/client.go:82 +0x11d
golang.org/x/crypto/ssh.Dial(0x791167, 0x3, 0xc420120700, 0xc, 0xc42004dd00, 0xc420120700, 0xc, 0x61a915)
	/usr/local/go/bin/src/golang.org/x/crypto/ssh/client.go:176 +0xb3
_/home/mmahajan/Prometheus/ssh_exporter/util.sshConnectToHost(0xc420120180, 0x9, 0xc4201201a8, 0x2, 0xc4201201b0, 0x4, 0xc420112b40, 0x1a, 0xc4200706b8, 0xc420026e78, ...)
	/home/mmahajan/Prometheus/ssh_exporter/util/main.go:347 +0x309
_/home/mmahajan/Prometheus/ssh_exporter/util.executeScriptOnHost(0xc420120180, 0x9, 0xc4201201a8, 0x2, 0xc4201201b0, 0x4, 0xc420112b40, 0x1a, 0xc420120140, 0xa, ...)
	/home/mmahajan/Prometheus/ssh_exporter/util/main.go:308 +0xd7
_/home/mmahajan/Prometheus/ssh_exporter/util.executeScript.func1(0xc420128230, 0xc420120140, 0xa, 0xc4200f7c40, 0xc420120640, 0xc4200a7900, 0xc420071380, 0xc4201205e0)
	/home/mmahajan/Prometheus/ssh_exporter/util/main.go:281 +0xa7
created by _/home/mmahajan/Prometheus/ssh_exporter/util.executeScript
	/home/mmahajan/Prometheus/ssh_exporter/util/main.go:299 +0x1a2
Config File:
version: v0
scripts:
  - name: "manik"
    script: "echo manik"
    timeout:  "5s"
    pattern: "manik"
    credentials:
    - host: "192.1681.34"
      port: 22
      user: 'root'
      keyfile: "/home/mmahajan/.ssh/id_rsa"

@jangrewe
Copy link

ssh: cannot decode encrypted private keys - looks like you need to use a non-encrypted private key.

@omadawn
Copy link
Contributor

omadawn commented Nov 11, 2017

Confirmed, we currently only support passwordless private keys.

I would like to avoid having a password in the config file but there might be other ways we could handle this.

We could read the passphrase from an environment variable.
We may be able to support ssh-agent allowing you to decrypt the keys ahead of time.

@manikSMahajan
Copy link
Author

instead accepting as key we can accept it as password, for this you have to do following changes

in main.go, change
Auth: []ssh.AuthMethod{
ssh.PublicKeys(key)

to
Auth: []ssh.AuthMethod{
ssh.Password(Password)

@omadawn
Copy link
Contributor

omadawn commented Jan 24, 2018

That would allow you to specify a password for the account instead of a key. Which would mean that you're storing an account password in a clear text file which we didn't implement because I'm comfortable with that.
However if someone issued a pull request which added it as an option config parameter instead of the key I would be willing to merge it in.

What would probably be better would be to unlock the key and store it with ssh-agent but I don't think that the ssh library will connect to it without some changes to the code.

Here's a simple example if you want to try it.
https://superuser.com/questions/133363/why-do-i-have-to-keep-unlocking-my-ssh-key

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

3 participants