amazon-ec2maven-3scpmaven-wagon-plugin

How to install files via maven-wagon-ssh/scp on an ec2 instance?


I am trying to copy some puppet files via scp on an ec2 ubuntu instance, using the maven-wagon-plugin. I've added the path of my private key file to my settings.xml and defined the usage of the plugin within my pom.xml (see below).

I can connect to the machine with putty. Also, wagon seems to be able to esatblish a connection, because it tells me:

   The authenticity of host 'ec2-....compute-1.amazonaws.com' can't be established. 
   RSA key fingerprint is 79:..:c7.
   Are you sure you want to continue connecting? (yes/no): yes

Yet, the plugin tells me that my auth is wrong:

    [ERROR] Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-   
    4:upload (upload-puppet-module) on project ...: 
    Unable to create a Wagon instance for scp://ec2-...compute-1.amazonaws.com/: 
    Cannot connect. Reason: Auth fail -> [Help 1] 

My settings.xml looks like this:

    ...
    <server>
        <id>ec2-node</id>                       
        <username>ubuntu</username>         
        <privateKey>.../path/to/privatekey.ppk</privateKey>         
    </server>        
    ...

My pom.xml looks like this:

<build>
    <extensions>
        <extension>
            <groupId>org.apache.maven.wagon</groupId>
            <artifactId>wagon-ssh</artifactId>
            <version>2.4</version>
        </extension>
    </extensions>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>wagon-maven-plugin</artifactId>
            <version>1.0-beta-4</version>
            <executions>
                <execution>
                    <id>upload-puppet-module</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>upload</goal>
                    </goals>
                    <configuration>
                        <id>ec2-node</id>
                        <fromDir>${basedir}/src/main/resources/puppet-module</fromDir>
                        <includes>*</includes>
                        <url>scp://ec2-...compute-1.amazonaws.com/</url>
                        <toDir>/etc/puppet/modules/</toDir>
                        <filePermissions>664</filePermissions>
                        <directoryPermissions>775</directoryPermissions>            
                    </configuration>
                </execution>
            </executions>

Any suggestions what I can do, to make it work ?

Thanks in advance!


Solution

  • I had a misspelling in the pom.xml. After rewritting the corresponding block, it worked :)

    Before:

    <plugins>
        <plugin>
         ...
         <configuration>
            <id>ec2-node</id> <-- Wrong
         ...
    

    After:

    <plugins>
        <plugin>
         ...
         <configuration>
            <serverId>ec2-node</serverId> <-- Right
         ...
    

    The addressed auth information, defined in the settings.xml, worked instantly.