Upload to private maven repo with apache maven wagon ssh | Unknown Host

1.3k Views Asked by At

I'm trying to upload my lib to private maven repo within our company. I'm able to access the server/repo via ssh from my mac/linux terminal, but I'm not able to configure wagen-ssh (2.2) to upload it to the repo.

i wrote the gradle task as described here: https://docs.gradle.org/current/userguide/maven_plugin.html

configurations {
    deployerJars
}
dependencies {
    ...
    deployerJars  'org.apache.maven.wagon:wagon-ssh:2.2+'
}

uploadArchives {
    repositories {
        mavenDeployer {
            configuration = configurations.deployerJars
            repository(url: "scp://{server}/var/www/maven") {
                authentication(userName: "myUsername", password: "myPassword")
            }
            pom.version = '0.1.0'
            pom.groupId = 'com.mycompany'
            pom.artifactId = 'mylib'

        }
    }
}

But everytime i try to execute the gradle task i get the error: Failed to deploy artifacts: Could not transfer artifact com.mycompany:mylib:aar:0.1.0 from/to remote (scp://{server}/var/www/maven): The host was not known and was not accepted by the configuration: {server}

I think wagon is using an own internal ssh client. How can i tell this client to accept my host, or accept any host?! Or am I wrong and there is another problem?

2

There are 2 best solutions below

1
Fabian On BEST ANSWER

Ok i found the solution myself: the entry in the known_hosts file for my server was with

ecdsa-sha2-nistp256

but the ssh client of wagon only understands rsa. So

ssh -o [email protected],ssh-rsa {yourhost}

does the magic.

0
Janning Vygen On

It is much easier if you use "ssh-external" dependency and "scpexe" as the protocol. Then the gradle process uses the same ssh as you use in your terminal and therefore will accept any ssh key your normal ssh programm does:

dependencies {
    bootArchives "org.apache.maven.wagon:wagon-ssh-external:3.4.0"
}

uploadBootArchives {
    repositories.mavenDeployer {
        configuration = configurations.bootArchives
        repository(url: "scpexe://yourhost/yourdir//")
    }
}