Changes for page SFTP Known Hosts
Last modified by Danniar Firdausy on 2024/09/18 20:35
From version 26.1
edited by Erik Bakker
on 2024/06/20 09:07
on 2024/06/20 09:07
Change comment:
There is no comment for this version
To version 28.1
edited by Erik Bakker
on 2024/06/20 09:19
on 2024/06/20 09:19
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -11,9 +11,9 @@ 11 11 12 12 == 2. Key concepts == 13 13 14 -This microlearning is about SFTP s ecurity.14 +This microlearning is about SFTP known host files. 15 15 16 -By SFTP s ecurity, we mean: Making sure thattheSFTPwe connect toknowsthatwe are indeedeMagiz16 +By SFTP known hosts, we mean: Making sure that we are certain that we connect to the correct SFTP to prevent data theft as a result of a "man in the middle" attack. 17 17 18 18 * Each SFTP has a unique fingerprint that identifies the SFTP. 19 19 * To prevent a "man in the middle" attack, this fingerprint needs to be stored client side. ... ... @@ -25,31 +25,35 @@ 25 25 26 26 There are two distinct ways of retrieving and storing the unique fingerprint of the SFTP in a "known hosts file". The first option is portal based and the second option is command line based. The preferred option is the portal based one. Do note that the first option only works if the SFTP is **publicly** accessible without any IP restrictions. 27 27 28 - Ifyouare looking for some introductoryreading intocertificates, please checkthis[[microlearning>>doc:Main.eMagizAcademy.Microlearnings.Novice.Securing Data Traffic.novice-securing-your-data-traffic-what-are-certificates.WebHome||target="blank"]].28 +=== 3.1 Known Hosts File Generation - Portal === 29 29 30 - As the private key is yours, you can ask a trusted party to generate the key, or you could create it yourself.The latter part happens a lotwhenconnectingto an SFTP. Youcould useatool like PuttyGen to achievethis. As aresult, you will havea keypair. The privatekey shouldbe keptsafely with you in eMagiz,and you need tosharethepublic key with the SFTP server party.Inthis microlearning,I will not explain howPuttyGen works in detail. Instead, wewillfocus on the partineMagiz. In eMagiz, we need torefer to the key file (linked under Resources),and we needto refer to the password we use to save our key file securely.30 +To configure the preferred option we start at the flow level in Create. 31 31 32 - [[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-security--private-key-config.png]]32 +=== 3.2 Known Hosts File Generation - Command Line === 33 33 34 -Note that the use of a password and a private key are mutually exclusive. So you need to either provide a password or a private key for authentication. In the help text provided by eMagiz, you can see how the reference to the key file should be made. 34 +The secondary option, when there are IP restrictions, provides you with the option to execute several commands after gaining access to the correct server to generate the known hosts file. These steps are detailed below. 35 + 36 +* Gain access to the server in question from which you can reach the SFTP. 37 +* Execute the following command (compatible with both Linux and Windows): {{code}}ssh-keyscan -p [port] [host] > [known-hosts target path]{{/code}} 38 +** An example would be: {{code}}ssh-keyscan -p 22 localhost > C:\tmp\generated_known_hosts{{/code}} 39 +* Navigate to the generated file and open it. The file should contain one or more lines in the format {{code}}hostname/ip key-type value 40 +e.g. 127.0.0.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAICZPI5pQ6PSXgS4QOPsai2QjC2EcVjFejvUM5RMYOmwbwW{{/code}} 41 +* Open eMagiz and navigate to the flow where the file is needed. 42 +* Upload the known_hosts file as a flow resource, and click on the "eye" icon to see its unique name. 43 +* Define a property for the known hosts field in the SFTP (caching) session factory. 44 +** Provide a value for the property upon deploying the release that follows the following structure: {{code}}classpath:emagiz-resources/[filename]{{/code}} 35 35 36 -When you have configured these settings, you have finished the configuration in eMagiz. Now you could test whether the configuration is set up correctly between eMagiz and the SFTP. If this is not the case, eMagiz will notify you via the Manage phase, either as an error message or a log entry. 37 - 38 -Using this setting gives the server the option to verify if the communication request came from eMagiz (or at least from the party that holds the private key of eMagiz). This is an additional security measure to ensure data integrity and quality. 39 - 40 40 == 4. Key takeaways == 41 41 42 -* Private key is unique per client 43 -* Private key should only be known to the client 44 -* Public key should be known to the SFTP (server), so they trust us when we set up the communication 45 -* A private key comes with a passphrase 48 +* Each SFTP has a unique fingerprint that identifies the SFTP. 49 +* To prevent a "man in the middle" attack, this fingerprint needs to be stored client side. 50 +* There are two distinct methods to generate the known hosts file. 46 46 47 47 == 5. Suggested Additional Readings == 48 48 49 49 If you are interested in this topic and want more information, please read the release notes provided by eMagiz. Furthermore, check out these links: 50 50 51 -* [[ SFTPOutbound>>https://docs.spring.io/spring-integration/docs/2.2.6.RELEASE/reference/html/sftp.html#sftp-outbound||target="blank"]]56 +* [[Known Hosts Files explained>>https://stackoverflow.com/questions/33243393/what-is-actually-in-known-hosts||target="blank"]] 52 52 * [[SFTP Session Factory>>https://docs.spring.io/spring-integration/docs/2.2.6.RELEASE/reference/html/sftp.html#sftp-session-factory||target="blank"]] 53 -* [[SFTP Authentication>>https://www.2brightsparks.com/resources/articles/sftp-authentication.html||target="blank"]] 54 54 55 55 )))((({{toc/}}))){{/container}}{{/container}}