You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

 

Introduction

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

The articles in this series are:

  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

For setting-up and running the examples see Using the tutorials with the JADE Client Command Line Interface

Public / Private Key Authentication with SFTP

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

Public/private key authentication

We assume here that users are familiar with the concepts of public/private key authentication.

To use public/private key authentication instead of password authentication the  *_ssh_auth_method parameter is set to:

  • _ssh_auth_method = publickey

and the *_user parameter is replaced with path of the private key file:

  • *_ssh_auth_file = C:\Users\myUserName\.ssh\demo_id_rsa

Example

  • Download the private key demo_id_rsa for the demo user.
    Note that the corresponding demo_id_rsa.pub public key has already been installed on our file transfer test system.
  • Save the public key in the jade_demo folder alongside the jade_settings_windows.ini file.
    • Ensure that the path to this file is iidentical to the value for the source_ssh_auth_file parameter listed in the profile below.
      Users of a Windows-Unix compatibility software such as Cygwin may prefer to use the location specified in the commented out source_ssh_auth_file parameter:
      • 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.
  • The profile listed below can be called from the jade_settings_windows.ini file.
    This profile is identical to the SFTP password profile described at the start of this article, with the exception of the parameters required for public/private key authentication and that a flie_spec parameter has been set.

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/jade/JADE_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

Call the profile using:

jade.cmd -settings="%USERPROFILE%\jade_demo\sos-berlin_demo_2_local_pub_priv_key.ini" -profile="sftp_server_2_local_pub_priv_key"

Behavior

Running the profile will cause the test.txt file to be downloaded after authentication has succeeded.

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

  • No labels