rtop icon indicating copy to clipboard operation
rtop copied to clipboard

unable to monitor server, error message not helpful.

Open Ghoughpteighbteau opened this issue 10 years ago • 16 comments

alex@alex-work ~/s/rtop (master)> ./rtop alex@my-demo:2299
rtop: asn1: structure error: tags don't match (16 vs {class:2 tag:1 length:76 isCompound:false}) {optional:false explicit:false application:false defaultValue:<nil> tag:<nil> stringType:0 set:false omitEmpty:false} pkcs1PrivateKey @2
alex@alex-work ~/s/rtop (master) [1]> ssh -p 2299 my-demo
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-24-generic x86_64)

so that's strange. I tried manually providing the private key to use, but the same result happened.

Keeping in mind that my private key is password protected, and the ssh-agent currently has access to it unencrypted.

Not sure what's going on :<

Ghoughpteighbteau avatar May 11 '15 15:05 Ghoughpteighbteau

Hmm, maybe it is picking up the key file auth method first, before the ssh-agent method. Can you try an experiment please?

  • comment out line 118 in sshhelper.go: auths = addPasswordAuth(auths)
  • recompile (make)
  • try again?

mdevan avatar May 11 '15 15:05 mdevan

alex@alex-work ~/s/rtop (master)> cat src/sshhelper.go | head -n 125 | tail -n 15
    return append(auths, ssh.PasswordCallback(passwordCallback))
}

func sshConnect(user, addr, keypath string) (client *ssh.Client) {
    auths := make([]ssh.AuthMethod, 0, 2)
    auths = addAgentAuth(auths)
    auths = addKeyAuth(auths, keypath)
    //auths = addPasswordAuth(auths)

    config := &ssh.ClientConfig{
        User: user,
        Auth: auths,
    }
    client, err := ssh.Dial("tcp", addr, config)
    if err != nil {
alex@alex-work ~/s/rtop (master)> make
GOPATH=`pwd` go build -o rtop src/*.go
alex@alex-work ~/s/rtop (master)> ./rtop my-demo:2299
rtop: asn1: structure error: tags don't match (16 vs {class:2 tag:1 length:76 isCompound:false}) {optional:false explicit:false application:false defaultValue:<nil> tag:<nil> stringType:0 set:false omitEmpty:false} pkcs1PrivateKey @2

for the record, and I don't know if this is explicitly the cause, but I use keychain rather than ssh-agent. It still registers the environment variables though. :\

Ghoughpteighbteau avatar May 11 '15 15:05 Ghoughpteighbteau

I think addAgentAuth is failing, because it should be getting the key from the agent.

Ghoughpteighbteau avatar May 11 '15 18:05 Ghoughpteighbteau

Hmm, it does for me. Can you try with a non-password-protected private key?

mdevan avatar May 12 '15 03:05 mdevan

Sorry for the slow reply. Now I'm REALLY confused.

alex@alex-work ~/s/rtop (master) [130]> keychain --clear

 * keychain 2.8.0 ~ http://www.funtoo.org
 * Found existing ssh-agent: 545
 * ssh-agent: All identities removed.

alex@alex-work ~/s/rtop (master)> ./rtop -i ~/.ssh/test_rsa my-demo:2299
Password: (ctrl-c)                                                                                                           
alex@alex-work ~/s/rtop (master) [2]> ssh -i ~/.ssh/test_rsa -p 2299 my-demo
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-24-generic x86_64)

wut.

the key works on its own, but fails on its own for rtop. How is that... what?!

Ghoughpteighbteau avatar May 12 '15 16:05 Ghoughpteighbteau

I can confirm that removing a passphrase from private key resolves this: ssh-keygen -p -N '' -f <key_file>

obviously, not something you want to do in general

thomasehardt avatar May 12 '15 16:05 thomasehardt

Yah I likely am hitting another issue entirely, it might not be related to the private key password.

Ghoughpteighbteau avatar May 12 '15 16:05 Ghoughpteighbteau

Please check with commit f753d19. With this rtop will natively support encrypted private keys, and also support auth via ssh-agent correctly.

mdevan avatar May 13 '15 14:05 mdevan

Ah it's asking me for a key now, I think this is likely working, but I may be suffering from a different issue as well, seeing as the unecrypted pup key doesn't work. I can't confirm this is a solved issue, should I open another one?

Ghoughpteighbteau avatar May 13 '15 16:05 Ghoughpteighbteau

Try with the latest commit ba5b35e. This improves the auth method handling.

mdevan avatar May 20 '15 05:05 mdevan

alex@alex-work ~/s/rtop ((ba5b35e...))> ./rtop my-demo:2299
Enter passphrase for key '/home/alex/.ssh/id_rsa': 
alex@my-demo's password: 
rtop: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey password], no supported methods remain
alex@alex-work ~/s/rtop ((ba5b35e...)) [1]> ssh -p 2299 my-demo
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-24-generic x86_64)

sooo there are some problems here. Even with the correct password that I just set on that machine, it fails to authenticate. It's not pulling the pubkey from the ssh agent (keychain).

this is frustrating, I don't understand what's going wrong here.

Ghoughpteighbteau avatar May 21 '15 18:05 Ghoughpteighbteau

Hmm, ssh appears to be using the agent, since it is not asking for the passphrase of the encrypted private key at ~/.ssh/id_rsa. (Or its reusing a connection via ControlMaster). Assuming the rtop was properly compiled off ba5b35e, this probably means that rtop is not able to talk to the agent.

Rtop uses the env var SSH_AUTH_SOCK to get the Unix socket name to talk to. This is usually set by running "eval $(ssh-agent)" in the shell. Can you check this flow?

mdevan avatar May 23 '15 07:05 mdevan

those environment variables are set.

alex@alex-work ~/s/rtop ((ba5b35e...))> env
...
SHLVL=4
SSH_AGENT_PID=545
SSH_AUTH_SOCK=/tmp/ssh-CjnTqN8e2L0y/agent.544
TERM=xterm-256color
...

so this is very strange!

Ghoughpteighbteau avatar May 25 '15 20:05 Ghoughpteighbteau

Is the env var being exported? Can you run "bash" again and in it "env" again?

mdevan avatar May 26 '15 01:05 mdevan

alex@alex-work ~/s/rtop ((ba5b35e...)) [1]> bash
[alex@alex-work rtop]$ env
...
SSH_AGENT_PID=545
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/alex
...
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/share/java/gradle/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl=
SSH_AUTH_SOCK=/tmp/ssh-CjnTqN8e2L0y/agent.544
MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins
MAVEN_OPTS=-Xmx512m

:(

also there really is something screwy going on here. I am connecting to a server that knows my public key, it also has a password and I provided that. I just can't connect to that server. Providing repeated correct credentials.

Ghoughpteighbteau avatar May 26 '15 17:05 Ghoughpteighbteau

Hmm. Try connecting to another server? Try running rtop from another machine?

mdevan avatar May 27 '15 05:05 mdevan