dacr / jassh

High level scala SSH API for easy and fast operations on remote servers.
Apache License 2.0
71 stars 27 forks source link

Simple "Hello World" example failing, and trying with password #31

Closed flyrev closed 7 years ago

flyrev commented 7 years ago

With

object Main extends App { import fr.janalyse.ssh._

val settings = SSHOptions( host = "localhost", username = "flyrev", identities = List(SSHIdentity("/home/flyrev/conf/ssh_keys/id_rsa")) )

SSH.once(settings) { ssh => print(ssh.execute("""echo "Hello World from hostname" """)) } }

I get

2017-03-30 13:25:52:996 +0200 [main] INFO JSCH - Connecting to localhost port 22 2017-03-30 13:25:53:003 +0200 [main] INFO JSCH - Connection established 2017-03-30 13:25:53:006 +0200 [main] INFO JSCH - Remote version string: SSH-2.0-OpenSSH_7.3p1 Ubuntu-1 2017-03-30 13:25:53:007 +0200 [main] INFO JSCH - Local version string: SSH-2.0-JSCH-0.1.53 2017-03-30 13:25:53:007 +0200 [main] INFO JSCH - CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256 2017-03-30 13:25:53:360 +0200 [main] INFO JSCH - aes256-ctr is not available. 2017-03-30 13:25:53:360 +0200 [main] INFO JSCH - aes192-ctr is not available. 2017-03-30 13:25:53:360 +0200 [main] INFO JSCH - aes256-cbc is not available. 2017-03-30 13:25:53:360 +0200 [main] INFO JSCH - aes192-cbc is not available. 2017-03-30 13:25:53:361 +0200 [main] INFO JSCH - CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521 2017-03-30 13:25:53:407 +0200 [main] INFO JSCH - CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - SSH_MSG_KEXINIT sent 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - SSH_MSG_KEXINIT received 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - kex: server: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - kex: server: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - kex: server: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - kex: server: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - kex: server: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - kex: server: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - kex: server: none,zlib@openssh.com 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - kex: server: none,zlib@openssh.com 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - kex: server: 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - kex: server: 2017-03-30 13:25:53:409 +0200 [main] INFO JSCH - kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1 2017-03-30 13:25:53:410 +0200 [main] INFO JSCH - kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521 2017-03-30 13:25:53:410 +0200 [main] INFO JSCH - kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc 2017-03-30 13:25:53:410 +0200 [main] INFO JSCH - kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc 2017-03-30 13:25:53:410 +0200 [main] INFO JSCH - kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96 2017-03-30 13:25:53:410 +0200 [main] INFO JSCH - kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96 2017-03-30 13:25:53:410 +0200 [main] INFO JSCH - kex: client: none 2017-03-30 13:25:53:410 +0200 [main] INFO JSCH - kex: client: none 2017-03-30 13:25:53:410 +0200 [main] INFO JSCH - kex: client: 2017-03-30 13:25:53:410 +0200 [main] INFO JSCH - kex: client: 2017-03-30 13:25:53:410 +0200 [main] INFO JSCH - kex: server->client aes128-ctr hmac-sha1 none 2017-03-30 13:25:53:410 +0200 [main] INFO JSCH - kex: client->server aes128-ctr hmac-sha1 none 2017-03-30 13:25:53:419 +0200 [main] INFO JSCH - SSH_MSG_KEX_ECDH_INIT sent 2017-03-30 13:25:53:420 +0200 [main] INFO JSCH - expecting SSH_MSG_KEX_ECDH_REPLY 2017-03-30 13:25:53:424 +0200 [main] INFO JSCH - ssh_rsa_verify: signature true 2017-03-30 13:25:53:426 +0200 [main] INFO JSCH - Permanently added 'localhost' (RSA) to the list of known hosts. 2017-03-30 13:25:53:427 +0200 [main] INFO JSCH - SSH_MSG_NEWKEYS sent 2017-03-30 13:25:53:427 +0200 [main] INFO JSCH - SSH_MSG_NEWKEYS received 2017-03-30 13:25:53:430 +0200 [main] INFO JSCH - SSH_MSG_SERVICE_REQUEST sent 2017-03-30 13:25:53:430 +0200 [main] INFO JSCH - SSH_MSG_SERVICE_ACCEPT received 2017-03-30 13:25:53:432 +0200 [main] INFO JSCH - Authentications that can continue: publickey,keyboard-interactive,password 2017-03-30 13:25:53:432 +0200 [main] INFO JSCH - Next authentication method: publickey 2017-03-30 13:25:53:433 +0200 [main] INFO JSCH - Authentications that can continue: password 2017-03-30 13:25:53:433 +0200 [main] INFO JSCH - Next authentication method: password 2017-03-30 13:25:53:438 +0200 [main] INFO JSCH - Disconnecting from localhost port 22 Exception in thread "main" com.jcraft.jsch.JSchException: SSH_MSG_DISCONNECT: 2 Too many authentication failures at com.jcraft.jsch.Session.read(Session.java:996) at com.jcraft.jsch.UserAuthPassword.start(UserAuthPassword.java:91) at com.jcraft.jsch.Session.connect(Session.java:463) at fr.janalyse.ssh.SSH.fr$janalyse$ssh$SSH$$buildSession(SSH.scala:304) at fr.janalyse.ssh.SSH.(SSH.scala:266) at fr.janalyse.ssh.SSH$.once(SSH.scala:57)

Any idea what's wrong?

flyrev commented 7 years ago

So there was a problem with authorized_keys. I guess the confusing thing was that it insisted on trying with a password. Is there a way of disabling that altogether, giving me "public key authentication failure" instead of that other message?