SFTPSend: Difference between revisions
Created page with "In summary sftpSend 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 https://github.com/C4J/sftpSend/releases GitHub. Note that the installer for Windows and MacOS contains a private bundl..." |
No edit summary |
||
Line 79: | Line 79: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Email Settings}} | |||
Latest revision as of 09:21, 8 September 2024
In summary sftpSend 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 [GitHub]. 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>
Encrypted settings
You can encrypt the settings held in the xml files above using a utility included.
Lets say you want to encrypt the password used for SFTP.
Open a command prompt and type the following
EncryptData
The program will load and prompt you for the string that you want to encrypt.
Password Utility Input data to encrypt :mysensitivepassword
The program will respond
Encrypted password saved to password.txt
You can then edit/view the contents of the password.txt file and amend the settings in the xml as follows
<value id="password" encrypted="no">mysensitivepassword</value>
<value id="password" encrypted="yes">ElxoCavGZP+i11w3+UhVqqggiJDPPAzxd7s+X2ZddxA=</value>
IMPORTANT - you need to amend the encrypted="no" setting and change it to encrypted="yes" so that the application knows.