Changes for page SFTP Known Hosts
Last modified by Danniar Firdausy on 2024/09/18 20:35
From version 32.1
edited by Erik Bakker
on 2024/06/20 10:15
on 2024/06/20 10:15
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 Known Hosts1 +SFTP Security - Parent
-
... ... @@ -1,1 +1,1 @@ 1 - Main.eMagiz Academy.Microlearnings.Intermediate Level.File based connectivity.WebHome1 +WebHome - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki.e bakker1 +XWiki.eMagiz - Default language
-
... ... @@ -1,1 +1,0 @@ 1 -en - Content
-
... ... @@ -1,9 +1,12 @@ 1 1 {{container}}{{container layoutStyle="columns"}}((( 2 2 3 -In anearlier[[microlearning>>Main.eMagizAcademy.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.IntermediateLevel.File based connectivity.intermediate-file-based-connectivity-sftp-security||target="blank"]]. In this microlearning, we want to expand our knowledge and look at away tostoretheuniquefingerprint ofthe SFTP to avoid thatsomeoneelsecanpretendtobe theSFTPwhenyouwanttosenddata(i.e.a"maninthemiddle attack").3 +In the last microlearning, we discussed how to connect to an SFTP from eMagiz. In this microlearning, we want to expand our knowledge and look at a more complex security configuration when connecting to SFTP instances. The configuration we are talking about is the private key configuration. 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 + 7 7 == 1. Prerequisites == 8 8 9 9 * Basic knowledge of the eMagiz platform ... ... @@ -11,71 +11,64 @@ 11 11 12 12 == 2. Key concepts == 13 13 14 -This microlearning is about SFTP known host files.17 +This microlearning is about SFTP security. 15 15 16 -By SFTP known hosts, we mean: Making sure thatwe are certain thatwe connect tothe correctSFTPto prevent datatheftas aresultof a "maninthe middle"attack.19 +By SFTP security, we mean: Making sure that the SFTP we connect to knows that we are indeed eMagiz 17 17 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. 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 21 21 22 -== 3. SFTP Known Hosts == 23 23 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". 25 25 26 - Therearetwo distinct ways of retrieving and storing the unique fingerprint of theSFTPin a "known hosts file". The first option is portal based and the second option is command line based. The preferred option isthe portal based one. Do note that the first option onlyworks if the SFTP is **publicly** accessible without any IP restrictions.28 +== 3. SFTP Security == 27 27 28 - ===3.1KnownHostsFileGeneration-Portal===30 +In the last microlearning, we discussed how to connect to an SFTP from eMagiz. In this microlearning, we want to expand our knowledge and look at a more complex security configuration when connecting to SFTP instances. The configuration we are talking about is the private key configuration. 29 29 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. 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 31 31 32 - [[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-known-hosts--sftp-session-factory-start.png]]37 +If you are looking for some introductory reading into certificates, please check this [microlearning](novice-securing-your-data-traffic-what-are-certificates.md). 33 33 34 - Once you see the configurationof the componentpleasedefine apropertyfortheknownhostsfield.Thispropertywill lateronbeusedtogenerate andstore the known hostsfilewhilein Deploy.39 +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 lot when connecting to an SFTP. You could use a tool like PuttyGen to achieve this. As a result, you will have a keypair. The private key should be kept safely with you in eMagiz, and you need to share the public key with the SFTP server party. In this microlearning, I will not explain how PuttyGen works in detail. Instead, we will focus on the part in eMagiz. In eMagiz, we need to refer to the key file (linked under Resources), and we need to refer to the password we use to save our key file securely. 35 35 36 -[[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp- known-hosts--sftp-session-known-hosts.png]]41 +[[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-security--private-key-config.png]] 37 37 38 - When you are satisfiedwith theconfigurationyoucansave it,press"Stop editing",andcreatea new version oftheflow. Now that wehave anew versionofthe flowwenavigate to theDeployphase totriggereMagizto generateandstoretheknown hosts filecorrectlyonruntimelevel.To do so we needto createtheproperty (with thecorrectname)inDeploy. If you are unsureonhow tocreatepropertiesinthe first place,please checkout this [[microlearning>>Main.eMagiz Academy.Microlearnings.IntermediateLevel.Filebasedconnectivity.intermediate-file-based-connectivity-sftp-connectivity||target="blank"]].43 +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. 39 39 40 -When definingthe value of thepropertywewhaveanadditional option inthe"Datatype" dropdowncalled"Known hostsString".Onceyouhaveselected thisacogwheeliconwill apearnexttothevaluefield.45 +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. 41 41 42 - [[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-known-hosts--known-hosts-string-property-start.png]]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. 43 43 44 -Pressing this cogwheel icon will open a new pop-up in which you need to define the port and the host you want to connect to. 45 45 46 -[[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-known-hosts--known-hosts-string-property-config-empty.png]] 47 47 48 - Afterfilling in the correct values press the button called "Generate known hosts string" to make sure that eMagiz will generate the file for you. Asa result, eMagiz will show you the correct stringthat defines the known host.51 +== 4. Assignment == 49 49 50 -[[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-known-hosts--known-hosts-string-property-generated.png]] 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. 51 51 52 - {{info}}Incaseyou havemultiple SFTP connections withinyourflow (or runtime) you should use distinct property placeholder for each SFTP to utilize this functionality.{{/info}}56 +== 5. Key takeaways == 53 53 54 -=== 3.2 Known Hosts File Generation - Command Line === 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 55 55 56 -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. 57 - 58 -* Gain access to the server in question from which you can reach the SFTP. 59 -* Execute the following command (compatible with both Linux and Windows): {{code}}ssh-keyscan -p [port] [host] > [known-hosts target path]{{/code}} 60 -** An example would be: {{code}}ssh-keyscan -p 22 localhost > C:\tmp\generated_known_hosts{{/code}} 61 -* 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 62 -e.g. 127.0.0.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAICZPI5pQ6PSXgS4QOPsai2QjC2EcVjFejvUM5RMYOmwbwW{{/code}} 63 -* Open eMagiz and navigate to the flow where the file is needed. 64 -* Upload the known_hosts file as a flow resource, and click on the "eye" icon to see its unique name. 65 -* Define a property for the known hosts field in the SFTP (caching) session factory. 66 -** Provide a value for the property upon deploying the release that follows the following structure: {{code}}classpath:emagiz-resources/[filename]{{/code}} 67 67 68 -== 4. Key takeaways == 69 69 70 -* Each SFTP has a unique fingerprint that identifies the SFTP. 71 -* To prevent a "man in the middle" attack, this fingerprint needs to be stored client side. 72 -* There are two distinct methods to generate the known hosts file. 65 +== 6. Suggested Additional Readings == 73 73 74 -== 5. Suggested Additional Readings == 75 - 76 76 If you are interested in this topic and want more information, please read the release notes provided by eMagiz. Furthermore, check out these links: 77 77 78 -* [[Known Hosts Files explained>>https://stackoverflow.com/questions/33243393/what-is-actually-in-known-hosts||target="blank"]] 79 -* [[SFTP Session Factory>>https://docs.spring.io/spring-integration/docs/2.2.6.RELEASE/reference/html/sftp.html#sftp-session-factory||target="blank"]] 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 80 80 73 +== 7. Silent demonstration video == 74 + 75 +As this is a more theoretical microlearning, there is no video. 76 + 81 81 )))((({{toc/}}))){{/container}}{{/container}}