Introduction

This is the sixth in a series of articles describing how to get started with using the the YADE Client via its Command Line Interface.

YADE Tutorials List

YADE Client Command Line Interface

  1. Getting Started and Downloading files
  2. Simple File Selection
  3. More Advanced File Selection
  4. File Transfer

  5. Checking files for completeness
  6. Public / Private Key Authentication
  7. Transfer via a Jump Host / DMZ

YADE Background Service

  1. Installation, Configuration and Use

Prerequisites

See the Using the tutorials with the YADE Client Command Line Interface article for guidelines to setting up and running these tutorial examples.

Instructions for installing, configuring and using the XML Editor can be found in the XML Editor series of articles.

Download the configuration file

The configuration described in this tutorial can be downloaded and then directly opened in the XML Editor using the following link:

Public / Private Key Authentication with SFTP

In addition to the password authentication described for FTP and SFTP in the first tutorial in this series YADE can use Public/Private Key Authentication.

In this tutorial we assume here that users are familiar with the concepts of public/private key authentication. Users wishing more information can find a detailed description of the principles behind this form of authentication in the Wikipedia, Public-key Cryptography article.

Public/private key configuration

Private Key

  • Download the private key demo_id_rsa for the demo user.
    The corresponding demo_id_rsa.pub public key has already been installed on our file transfer test system.
  • Save the private key in the jade_demo folder alongside the sos-berlin_demo_2_local_pub_priv_key.xml file.

ProtocolFragment

The example presented in this tutorial uses a ProtocolFragment based on the sftp_demo_sos-berlin_pass fragment described in the first tutorial in this series and which used password authentication.

To use public/private key authentication instead of password authentication:

  • the AuthenticationMethodPassword element is replaced with an AuthenticationMethodPublickey element and
  • an AuthenticationFile element as shown in the XML Editor screenshot below.
    Ensure that the path entered for this element is iidentical to the path used for the demo user's demo_id_rsa private key.
    • Users of a Windows-Unix compatibility software such as Cygwin may prefer to use alternative locations:
      • For Windows users:
        • %USERPROFILE%\.ssh\demo_id_rsa
          where %USERPROFILE% is the path to your Windows user home directory.
      • For Unix users:
        • ${HOME}\.ssh\demo_id_rsa
          where ${HOME} is the path to your user's home directory.

Note that the private key itself can be protected by a passphrase that can be specified with a Passphrase child of the AuthenticationMethodPublicKey element.

Profile

Apart from a changed profile_id and SFTPFragmentRef ref attributes, the Profile in this tutorial is identical to that used in the password authentication example described in the first tutorial in this series.

XML Editor Configuration

The Profile Code

The following code boxes can be opened to show the Profile and ProtocolFragments used in this example in XML and in settings.ini formats.

The 'ftp_server_2_local_pub_priv_key' Profile in XML Format
 <?xml version="1.0" encoding="utf-8"?>
<Configurations xsi:noNamespaceSchemaLocation="http://www.sos-berlin.com/schema/yade/YADE_configuration_v1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Fragments>
    <ProtocolFragments>
      <SFTPFragment name="sftp_demo_sos-berlin_pub_priv_key">
        <BasicConnection>
          <Hostname><![CDATA[test.sos-berlin.com]]></Hostname>
        </BasicConnection>
        <SSHAuthentication>
          <Account><![CDATA[demo]]></Account>
          <AuthenticationMethodPublickey>
            <AuthenticationFile><![CDATA[${USERPROFILE}\jade_demo\demo_id_rsa]]></AuthenticationFile>
          </AuthenticationMethodPublickey>
        </SSHAuthentication>
      </SFTPFragment>
    </ProtocolFragments>
  </Fragments>
  <Profiles>
    <Profile profile_id="sftp_server_2_local_pub_priv_key">
      <Operation>
        <Copy>
          <CopySource>
            <CopySourceFragmentRef>
              <SFTPFragmentRef ref="sftp_demo_sos-berlin_pub_priv_key" />
            </CopySourceFragmentRef>
            <SourceFileOptions>
              <Selection>
                <FileSpecSelection>
                  <FileSpec><![CDATA[.*]]></FileSpec>
                  <Directory><![CDATA[./]]></Directory>
                </FileSpecSelection>
              </Selection>
            </SourceFileOptions>
          </CopySource>
          <CopyTarget>
            <CopyTargetFragmentRef>
              <LocalTarget />
            </CopyTargetFragmentRef>
            <Directory><![CDATA[${USERPROFILE}\jade_demo\a]]></Directory>
          </CopyTarget>
        </Copy>
      </Operation>
    </Profile>
  </Profiles>
</Configurations>
The 'ftp_server_2_local_pub_priv_key' Profile in settings.ini Format
[protocol_fragment_sftp@sftp_demo_sos-berlin_pub_priv_key]
protocol                            = sftp

host                                = test.sos-berlin.com
user                                = demo
ssh_auth_method                     = publickey
ssh_auth_file                       = ${USERPROFILE}\jade_demo\demo_id_rsa

[sftp_server_2_local_pub_priv_key]
operation                           = copy

source_include                      = protocol_fragment_sftp@sftp_demo_sos-berlin_pub_priv_key
file_spec                           = .*
source_dir                          = ./

target_protocol                     = local
target_dir                          = ${USERPROFILE}\jade_demo\a

Running the Profile

This profile is called on Windows systems using one of the following commands, depending on the YADE version being used:

Running the file transfer settings.ini configuration in Windows format (YADE 1.10 and earlier)
jade.cmd -settings="%USERPROFILE%\jade_demo\sos-berlin_demo_2_local_pub_priv_key.ini" -profile="sftp_server_2_local_pub_priv_key"
Running the file transfer XML configuration in Windows format (YADE 1.11 and later)
jade.cmd -settings="%USERPROFILE%\jade_demo\sos-berlin_demo_2_local_pub_priv_key.xml" -profile="sftp_server_2_local_pub_priv_key"

On Unix systems the profile is called using one of the following commands, depending on the YADE version being used:

Running the file transfer settings.ini configuration in Unix format (YADE 1.10 and earlier)
./jade.sh -settings="${HOME}/jade_demo/sos-berlin_demo_2_local_pub_priv_key.ini" -profile="sftp_server_2_local_pub_priv_key"
Running the file transfer XML configuration in Unix format (YADE 1.11 and later)
./jade.sh -settings="${HOME}/jade_demo/sos-berlin_demo_2_local_pub_priv_key.xml" -profile="sftp_server_2_local_pub_priv_key"

Behavior

Running the profile will cause six files to be downloaded after authentication has succeeded.

The connection will be ended after the download has been completed.