Changes for page SFTP Known Hosts
Last modified by Danniar Firdausy on 2024/09/18 20:35
From version 25.2
edited by Erik Bakker
on 2024/06/20 08:44
on 2024/06/20 08:44
Change comment:
Update document after refactoring.
To version 34.14
edited by Danniar Firdausy
on 2024/09/18 20:35
on 2024/09/18 20:35
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. ebakker1 +XWiki.dfirdausy - Content
-
... ... @@ -1,6 +1,6 @@ 1 1 {{container}}{{container layoutStyle="columns"}}((( 2 2 3 -In the lastmicrolearning,we discussed how to connect to an SFTPfromeMagiz.Inthismicrolearning,we want toexpand ourknowledgeandlookata morecomplexsecurity configurationwhenconnecting toSFTPinstances. Theconfigurationweare talking about istheprivatekey configuration.3 +In our previous [[microlearning>>Main.eMagiz Academy.Microlearnings.Intermediate Level.File based connectivity.intermediate-file-based-connectivity-sftp-connectivity||target="blank"]], we explored how to connect to an SFTP server using eMagiz and discussed an alternative security method for authentication. Now, we are going to delve deeper into securing your SFTP connections by storing the server’s unique fingerprint to protect against "man in the middle" attacks. This microlearning will guide you through the process of generating and managing a "known hosts" file to ensure you're always connecting to the correct SFTP server. 4 4 5 5 Should you have any questions, please get in touch with [[academy@emagiz.com>>mailto:academy@emagiz.com]]. 6 6 ... ... @@ -11,49 +11,78 @@ 11 11 12 12 == 2. Key concepts == 13 13 14 -This microlearning is about SFTP security. 14 +This microlearning is about SFTP known host files. 15 +* 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. 15 15 16 - BySFTPsecurity, we mean: Making sure that theSFTPwe connecttoknowshatwe are indeed eMagiz17 +== 3. SFTP Known Hosts == 17 17 18 -* Private key is unique per client 19 -* Private key should only be known to the client 20 -* Public key should be known to the SFTP (server), so they trust us when we set up the communication 21 -* A private key comes with a passphrase 19 +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". 22 22 23 -== 3. SFTP Security == 21 +* Each SFTP has a unique fingerprint that identifies the SFTP. 22 +* To prevent a "man in the middle" attack, this fingerprint needs to be stored client side. 23 +* There are two distinct methods to generate the known hosts file. 24 24 25 - In thelastmicrolearning,wediscussedhow to connecttoanSFTPfromeMagiz.Inthismicrolearning,wewanttoexpandourknowledgeandlook atamorecomplexsecurityconfigurationwhenconnectingtoSFTP instances.Theconfigurationweare talkingaboutisthe privatekeyconfiguration.25 +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. 26 26 27 -* Private key is unique per client 28 -* Private key should only be known to the client 29 -* Public key should be known to the SFTP (server), so they trust us when we set up the communication 30 -* A private key comes with a passphrase 27 +=== 3.1 Known Hosts File Generation - Portal === 31 31 32 - If youare lookingforsomeintroductoryreadingintocertificates,please checkthis[[microlearning>>doc:Main.eMagizAcademy.Microlearnings.Novice.SecuringDataTraffic.novice-securing-your-data-traffic-what-are-certificates.WebHome||target="blank"]].29 +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. 33 33 34 - As the privatekey is yours, you cansk a trusted party togenerate the key, or youcould create it yourself. Thelatterpart happens a lot when connectingto an SFTP.You could usea tool likePuttyGeno achieve this. As aresult, you will have a keypair. The privatekey should be kept safely with you ineMagiz, andyouneedto share the public key with the SFTP server party. In thismicrolearning, I will notexplainhowPuttyGenworksin detail. Instead, we will focusonthepart ineMagiz. IneMagiz, we needtoefer to the keyfile (linked under Resources), and we needto refer to the password we useto save our key file securely.31 +[[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-known-hosts--sftp-session-factory-start.png]] 35 35 36 - [[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-security--private-key-config.png]]33 +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. 37 37 38 - Note that theuse ofapasswordand a privatekey aremutuallyexclusive. So youneedto either providepasswordr a private keyor authentication. In the helptextrovided by eMagiz, you cansee howthe reference tohe key fileshould be made.35 +[[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-known-hosts--sftp-session-known-hosts.png]] 39 39 40 -When you haveconfigured thesesettings,youhave finishedtheconfiguration in eMagiz. NowyoucouldtestwhethertheconfigurationissetupcorrectlybetweeneMagizand theSFTP. Ifthisis not the case,eMagizwillnotify youviatheManage phase, either asan errormessage ory.37 +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. To do so we need to create the property (with the correct name) in Deploy. If you are unsure on how to create properties in the first place, please check out this [[property management>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course Platform.crashcourse-platform-deploy-property-management-new.WebHome||target="blank"]] microlearning. 41 41 42 - Usingthis settinggivestheserverthe optionto verifyifthe communicationrequestcamefrom eMagiz (oratleastfromthepartythatholdsthe privatekeyof eMagiz). Thisis anadditionalsecurity measureto ensuredataintegrityand quality.39 +When defining the value of the property we now have an additional option in the "Data type" dropdown called "Known hosts String". Once you have selected this a cogwheel icon will apear next to the value field. 43 43 41 +[[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-known-hosts--known-hosts-string-property-start.png]] 42 + 43 +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. 44 + 45 +[[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-known-hosts--known-hosts-string-property-config-empty.png]] 46 + 47 +After filling in the correct values press the button called "Generate known hosts string" to make sure that eMagiz will generate the file for you. As a result, eMagiz will show you the correct string that defines the known host. 48 + 49 +[[image:Main.Images.Microlearning.WebHome@intermediate-file-based-connectivity-sftp-known-hosts--known-hosts-string-property-generated.png]] 50 + 51 +{{info}}In case you have multiple SFTP connections within your flow (or runtime) you should use distinct property placeholder for each SFTP to utilize this functionality.{{/info}} 52 + 53 +=== 3.2 Known Hosts File Generation - Command Line === 54 + 55 +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. 56 + 57 +* Gain access to the server in question from which you can reach the SFTP. 58 +* Execute the following command (compatible with both Linux and Windows): {{code}}ssh-keyscan -p [port] [host] > [known-hosts target path]{{/code}} 59 +** An example would be: {{code}}ssh-keyscan -p 22 localhost > C:\tmp\generated_known_hosts{{/code}} 60 +* 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 61 +e.g. 127.0.0.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAICZPI5pQ6PSXgS4QOPsai2QjC2EcVjFejvUM5RMYOmwbwW{{/code}} 62 +* Open eMagiz and navigate to the flow where the file is needed. 63 +* Upload the known_hosts file as a flow resource, and click on the "eye" icon to see its unique name. 64 +* Define a property for the known hosts field in the SFTP (caching) session factory. 65 +** Provide a value for the property upon deploying the release that follows the following structure: {{code}}classpath:emagiz-resources/[filename]{{/code}} 66 + 44 44 == 4. Key takeaways == 45 45 46 -* Private key is unique per client 47 -* Private key should only be known to the client 48 -* Public key should be known to the SFTP (server), so they trust us when we set up the communication 49 -* A private key comes with a passphrase 69 +* Each SFTP server has a unique fingerprint that serves as its identifier. 70 +* To protect against "man in the middle" attacks, you must securely store this fingerprint on the client side. 71 +* There are two methods for generating and managing the known hosts file: a portal-based approach and a command-line approach. The portal-based method is preferred for publicly accessible SFTP servers without IP restrictions. 50 50 51 51 == 5. Suggested Additional Readings == 52 52 53 53 If you are interested in this topic and want more information, please read the release notes provided by eMagiz. Furthermore, check out these links: 54 54 55 -* [[SFTP Outbound>>https://docs.spring.io/spring-integration/docs/2.2.6.RELEASE/reference/html/sftp.html#sftp-outbound||target="blank"]] 56 -* [[SFTP Session Factory>>https://docs.spring.io/spring-integration/docs/2.2.6.RELEASE/reference/html/sftp.html#sftp-session-factory||target="blank"]] 57 -* [[SFTP Authentication>>https://www.2brightsparks.com/resources/articles/sftp-authentication.html||target="blank"]] 77 +* [[Crash Course (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.WebHome||target="blank"]] 78 +** [[Crash Course Platform (Navigation)>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course Platform.WebHome||target="blank"]] 79 +*** [[Property Management (Explanation)>>doc:Main.eMagiz Academy.Microlearnings.Crash Course.Crash Course Platform.crashcourse-platform-deploy-property-management-new.WebHome||target="blank"]] 80 +* [[Intermediate Level (Menu)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.WebHome||target="blank"]] 81 +** [[File based connectivity (Navigation)>>doc:Main.eMagiz Academy.Microlearnings.Intermediate Level.File based connectivity.WebHome||target="blank"]] 82 +*** [[SFTP Connectivity (Explanation)>>Main.eMagiz Academy.Microlearnings.Intermediate Level.File based connectivity.intermediate-file-based-connectivity-sftp-connectivity||target="blank"]] 83 +*** [[SFTP Security (Explanation)>>Main.eMagiz Academy.Microlearnings.Intermediate Level.File based connectivity.intermediate-file-based-connectivity-sftp-security||target="blank"]] 84 +* [[Known Hosts (Search Results)>>url:https://docs.emagiz.com/bin/view/Main/Search?sort=score&sortOrder=desc&highlight=true&facet=true&r=1&f_space_facet=0%2FMain.&l_space_facet=10&f_type=DOCUMENT&f_locale=en&f_locale=&f_locale=en&text=%22known+hosts%22||target="blank"]] 85 +* [[Known Hosts Files explained (External)>>https://stackoverflow.com/questions/33243393/what-is-actually-in-known-hosts||target="blank"]] 86 +* [[SFTP Session Factory (External)>>https://docs.spring.io/spring-integration/docs/2.2.6.RELEASE/reference/html/sftp.html#sftp-session-factory||target="blank"]] 58 58 59 59 )))((({{toc/}}))){{/container}}{{/container}}