1

I am trying to connnect to remote machine using gradle-ssh-plugin(detail here: https://gradle-ssh-plugin.github.io/docs/#_run_the_script). When I am executing the task, I am getting the following error:

Caused by: com.jcraft.jsch.JSchException: java.net.ConnectException: Connection refused: connect

plugins {
    id 'org.hidetake.ssh' version '2.0.0'
    id 'java'
}

repositories {
        mavenCentral()
}

dependencies {
        compile 'org.hidetake:gradle-ssh-plugin:2.0.0'
        compile 'org.codehaus.groovy:groovy-backports-compat23:2.4.6'
}    
remotes {
        vesper01 {
            host = 'cpt-op-01-load1'
            user = 'CPT-OP\\admin'
            password = 'password'
        }
        vesper02 {
            host = 'cpt-op-01-load2'
            user = 'CPT-OP\\admin'
            password = 'password'
        }
        vesper03 {
            host = 'cpt-op-01-load3'
            user = 'CPT-OP\\admin'
            password = 'password'
        }
    }

    task install_dependencies_on_load_vms << {
        logger.info "Running Vesper on remote machine..."
        ssh.settings {
            knownHosts = allowAnyHosts
        }
        ssh.run {
            session(remotes.vesper01) {
                execute "C:/vesper_cpt/vespersetup.exe /S runas 5"
            }
        }
    }

Could any one point me to the right direction?

rapport89
  • 109
  • 3
  • 14
  • Connection refused means that the destination server **actively** refused the connection. This is more then likely an issue in _your_ configuration, not an issue with your gradle file or plugin. – Matt Clark Apr 07 '16 at 21:26
  • Ok that's good to know but I am not sure what to check for at destination server to make this work. Could you please provide any suggestion about this? – rapport89 Apr 07 '16 at 21:27
  • From the machine you are running this from, can you execute `ssh CPT-OP\\admin@cpt-op-01-load1`, my guess is that this also will return `Connection Refused`. – Matt Clark Apr 07 '16 at 21:29
  • It does not say connection refused but: 'port22: Bad file number'. I googled it and found this link http://stackoverflow.com/questions/7144811/git-ssh-error-connect-to-host-bad-file-number . Just to let you know that I have not setup anything related to SSH before running my build.gradle script. So, I am wondering there is more to be done here before this script works. Any suggestion are appreciated. – rapport89 Apr 07 '16 at 21:34
  • so.... are those hosts actually running `sshd`? The SSH server? – Matt Clark Apr 07 '16 at 21:46
  • No, its not running SSH server. This is happening because of that. Could you please explain in brief what should I be doing to install ssh server? – rapport89 Apr 07 '16 at 22:18

1 Answers1

1

java.net.ConnectException: Connection refused: connect usually means that the host is not reachable or the service you are trying to reach is not running. Are you sure on the target system there is an SSH daemon running and it is listening on the port and interface you try to connect to?

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • SSH was not running on remote machine and now after having SSH on remote machine. It is working fine. Though, I also find a gradle plugin 'groowin' which is much easier to implement and use. Please find the plugin here: https://github.com/aestasit/groowin-gradle . Also, can you accept my question so that it can be useful for others. Thanks! – rapport89 Apr 12 '16 at 16:12