Changes for page SFTP Known Hosts
Last modified by Danniar Firdausy on 2024/09/18 20:35
From version 20.1
edited by eMagiz
on 2022/06/10 12:10
on 2022/06/10 12:10
Change comment:
There is no comment for this version
To version 29.1
edited by Erik Bakker
on 2024/06/20 09:30
on 2024/06/20 09:30
Change comment:
There is no comment for this version
Summary
-
Page properties (5 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 -SFTP Security1 +SFTP Known Hosts - Parent
-
... ... @@ -1,1 +1,1 @@ 1 -WebHome 1 +Main.eMagiz Academy.Microlearnings.Intermediate Level.File based connectivity.WebHome - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki.e Magiz1 +XWiki.ebakker - Default language
-
... ... @@ -1,0 +1,1 @@ 1 +en - Content
-
... ... @@ -1,12 +1,9 @@ 1 1 {{container}}{{container layoutStyle="columns"}}((( 2 2 3 -In the lastmicrolearning, we discussed how to connect to an SFTP from eMagiz. In this microlearning, we want to expand our knowledge and look at amorecomplexsecurityconfigurationwhenconnectingtoSFTPinstances.Theconfigurationwe aretalkingaboutistheprivatekey configuration.3 +In an earlier [[microlearning>>Main.eMagiz Academy.Microlearnings.Intermediate Level.File based connectivity.intermediate-file-based-connectivity-sftp-connectivity||target="blank"]], we discussed how to connect to an SFTP from eMagiz. Later on we zoomed in on an alternative security method to authenticate yourself at the SFTP. More on this can be found in this [[microlearning>>Main.eMagiz Academy.Microlearnings.Intermediate Level.File based connectivity.intermediate-file-based-connectivity-sftp-security||target="blank"]]. In this microlearning, we want to expand our knowledge and look at a way to store the unique fingerprint of the SFTP to avoid that someone else can pretend to be the SFTP when you want to send data (i.e. a "man in the middle attack"). 4 4 5 5 Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]]. 6 6 7 -* Last update: August 25th, 2021 8 -* Required reading time: 9 minutes 9 - 10 10 == 1. Prerequisites == 11 11 12 12 * Basic knowledge of the eMagiz platform ... ... @@ -14,64 +14,57 @@ 14 14 15 15 == 2. Key concepts == 16 16 17 -This microlearning is about SFTP s ecurity.14 +This microlearning is about SFTP known host files. 18 18 19 -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. 20 20 21 -* Private key is unique per client 22 -* Private key should only be known to the client 23 -* Public key should be known to the SFTP (server), so they trust us when we set up the communication 24 -* A private key comes with a passphrase 18 +* Each SFTP has a unique fingerprint that identifies the SFTP. 19 +* To prevent a "man in the middle" attack, this fingerprint needs to be stored client side. 20 +* There are two distinct methods to generate the known hosts file. 25 25 22 +== 3. SFTP Known Hosts == 26 26 24 +In this microlearning, we want to expand our knowledge and look at a way to store the unique fingerprint of the SFTP to avoid that someone else can pretend to be the SFTP when you want to send data (i.e. a "man in the middle attack"). To retrieve the unique fingerprint of an SFTP you first need to connect to the SFTP in question. This way you can retrieve the unique fingerprint and secure it in a file for future use to prevent the "man in the middle attack". 27 27 28 - ==3.SFTPSecurity==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. 29 29 30 - Inthelast microlearning, we discussed howto connecttoan SFTP from eMagiz. Inthismicrolearning,wewant toexpand ourknowledgeand look ata more complex security configurationwhenconnecting to SFTPinstances. The configuration weare talkingabout is the private key configuration.28 +=== 3.1 Known Hosts File Generation - Portal === 31 31 32 -* Private key is unique per client 33 -* Private key should only be known to the client 34 -* Public key should be known to the SFTP (server), so they trust us when we set up the communication 35 -* A private key comes with a passphrase 30 +To configure the preferred option we start at the flow level in Create. Once the flow is opened please enter "Start Editing" mode and navigate to the Support object tab in the right panel. In here open the SFTP (caching) session factory that is used to connect to the SFTP. 36 36 37 - If youarelooking for somentroductory readingo certificates, pleaseheckthis [microlearning](novice-securing-your-data-traffic-what-are-certificates.md).32 +[[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-known-hosts--sftp-session-factory-start.png]] 38 38 39 - As theprivate keyis yours,you can ask a trusted party to generatethekey, or youcould createityourself.The latter parthappensa lot whenconnectingtoan SFTP. You could usetool likePuttyGen to achievethis. Asa result, you will have a keypair. Theprivate keyshouldbe keptsafely withyou ineMagiz,and youneedtoharethepublic key with the SFTP server party.In thismicrolearning,Iwillnot explain how PuttyGen worksindetail.Instead,we will focusonthepartineMagiz.In eMagiz, weneed toferto the key file (linked under Resources), andweneedto refer to the password we usetosaveour keyfilesecurely.34 +Once you see the configuration of the component please define a property for the known hosts field. This property will later on be used to generate and store the known hosts file while in Deploy. 40 40 41 -[[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-s ecurity--private-key-config.png]]36 +[[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-known-hosts--sftp-session-known-hosts.png]] 42 42 43 - Note thatthe useofapassword anda privatekeyaremutuallyexclusive. Soyouneedtoeitherprovide apasswordora privatekeyforauthentication.Inthehelp textprovidedbyeMagiz,youcansee howthereferenceto the keyfileshouldbemade.38 +When you are satisfied with the configuration you can save it, press "Stop editing", and create a new version of the flow. Now that we have a new version of the flow we navigate to the Deploy phase to trigger eMagiz to generate and store the known hosts file correctly on runtime level. 44 44 45 - Whenyouhave configuredthese settings,you have finishedtheconfiguration ineMagiz. Now you could test whetherthe configurationisset up correctly between eMagiz andthe SFTP. If this isnot thecase, eMagiz will notify you via the Manage phase, either as an error message or a log entry.40 +=== 3.2 Known Hosts File Generation - Command Line === 46 46 47 -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. 42 +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. 43 + 44 +* Gain access to the server in question from which you can reach the SFTP. 45 +* Execute the following command (compatible with both Linux and Windows): {{code}}ssh-keyscan -p [port] [host] > [known-hosts target path]{{/code}} 46 +** An example would be: {{code}}ssh-keyscan -p 22 localhost > C:\tmp\generated_known_hosts{{/code}} 47 +* 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 48 +e.g. 127.0.0.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAICZPI5pQ6PSXgS4QOPsai2QjC2EcVjFejvUM5RMYOmwbwW{{/code}} 49 +* Open eMagiz and navigate to the flow where the file is needed. 50 +* Upload the known_hosts file as a flow resource, and click on the "eye" icon to see its unique name. 51 +* Define a property for the known hosts field in the SFTP (caching) session factory. 52 +** Provide a value for the property upon deploying the release that follows the following structure: {{code}}classpath:emagiz-resources/[filename]{{/code}} 48 48 54 +== 4. Key takeaways == 49 49 56 +* Each SFTP has a unique fingerprint that identifies the SFTP. 57 +* To prevent a "man in the middle" attack, this fingerprint needs to be stored client side. 58 +* There are two distinct methods to generate the known hosts file. 50 50 51 -== 4.Assignment==60 +== 5. Suggested Additional Readings == 52 52 53 -Check within your project(s) whether an SFTP connection is secured with the help of private key construction. 54 -This assignment can be completed with the help of the (Academy) project that you have created/used in the previous assignment. 55 - 56 -== 5. Key takeaways == 57 - 58 -* Private key is unique per client 59 -* Private key should only be known to the client 60 -* Public key should be known to the SFTP (server), so they trust us when we set up the communication 61 -* A private key comes with a passphrase 62 - 63 - 64 - 65 -== 6. Suggested Additional Readings == 66 - 67 67 If you are interested in this topic and want more information, please read the release notes provided by eMagiz. Furthermore, check out these links: 68 68 69 -* https://docs.spring.io/spring-integration/docs/2.2.6.RELEASE/reference/html/sftp.html#sftp-outbound 70 -* https://docs.spring.io/spring-integration/docs/2.2.6.RELEASE/reference/html/sftp.html#sftp-session-factory 71 -* https://www.2brightsparks.com/resources/articles/sftp-authentication.html 64 +* [[Known Hosts Files explained>>https://stackoverflow.com/questions/33243393/what-is-actually-in-known-hosts||target="blank"]] 65 +* [[SFTP Session Factory>>https://docs.spring.io/spring-integration/docs/2.2.6.RELEASE/reference/html/sftp.html#sftp-session-factory||target="blank"]] 72 72 73 -== 7. Silent demonstration video == 74 - 75 -As this is a more theoretical microlearning, there is no video. 76 - 77 77 )))((({{toc/}}))){{/container}}{{/container}}