Skip to content
David Garratt edited this page Jun 15, 2024 · 13 revisions

In summary sftpPut is a utility which is designed to run as a service and it's purpose is to monitor a local folder for a file or files matching a mask and if found upload them to a remote SFTP machine. The local file is then removed.

See the partner program called sftpGet

Installation

Download the installer for your operating system from Releases. Note that the installer for Windows and MacOS contains a private bundled Jave runtime. However the Linux version requires you to have a Java 17 runtime installed on your distro.

I recommend that you don't install into Program Files folder on windows as this will encounter problems with read-only folder permissions.

Once installed you need to configure the application using the two xml config files shown below.

The program can be run from the command line in a terminal window, or configured as a service for unattended operation.

If you want to setup the program to run as a service you need to open a command prompt with Admininstrator permissions, change into the folder where you installed the application and then run the command line as shown below.

sftpSend_Service /install sftp_Send

You will then need to open up the services control panel within windows and change the account which the program uses to run. By default it will be "System" but you will probably need to create a windows account which has permissions to access the folder that you want to monitor for files.

Configuration

Folder Structure

SFTP Send
├── Images
├── lib
│   ├── app
│   ├── license
│   └── mail
├── logs
├── send
│   └── demo
├── ssh
└── xml
    └── config


config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    
    <sftpSend2>

	<general>
            <value id="title" encrypted="no">SFTP Example</value>
	    <value id="emailEnabled" encrypted="no">false</value>
	</general>

        <security>
            <value id="remoteHost" encrypted="no">1.2.3.4</value>
            <value id="remotePort" encrypted="no">22</value>
            <value id="checkKnownHosts" encrypted="no">no</value>
            <value id="knownHostsFile" encrypted="no">./ssh/known_hosts</value>
            <value id="authType" encrypted="no">user password</value>
            <value id="username" encrypted="no">testuser</value>
            <value id="password" encrypted="no">testpassword</value>
            <value id="privateKeyFile" encrypted="no">./ssh/sftpSend</value>
            <value id="privateKeyPasswordProtected" encrypted="no">no</value>
            <value id="privateKeyPassword" encrypted="no"/>
        </security>

        <source>
            <value id="localDir" encrypted="no">./send/</value>
            <value id="localFileMask" encrypted="no">*.xml</value>
            <value id="backupDir" encrypted="no"></value>
            <value id="pollFrequencySeconds" encrypted="no">5000</value>
        </source>

        <destination>
            <value id="remoteDir" encrypted="no">/remote/</value>
            <value id="tempFileExtension" encrypted="no">.tmp</value>
        </destination>

    </sftpSend2>

</config>

email.xml

<?xml version="1.0" encoding="UTF-8"?>
<emailSettings>    
    
    <configuration>
        <property name="mail.smtp.auth" value="true"/>
        <property name="mail.smtp.starttls.enable" value="true"/>
        <property name="mail.smtp.host" value="smtp.live.com"/>
        <property name="mail.smtp.socketFactory.port" value="25"/>
        <property name="mail.smtp.user" value="email@outlook.com"/>
        <property name="mail.smtp.password" value="password"/>
        <property name="mail.smtp.socketFactory.class" value="javax.net.ssl.SSLSocketFactory"/>
        <property name="mail.smtp.auth" value="true"/>
        <property name="mail.smtp.port" value="25"/>
        <property name="mail.smtp.from" value="email@outlook.com"/>
        <property name="mail.debug" value="true"/>
    </configuration>

    <distributionList id="Monitor" enabled="Y" maxFrequencyMins="0">
        <toAddressList>example@email.com</toAddressList>
    </distributionList>

</emailSettings>
Clone this wiki locally