Generation of SFTP Known_Host File – Cloud Platform Integration
Introduction: Known Hosts is much like how the authorized_keys file is used to authenticate users the known_hosts file is used to authenticate servers. Whenever SSH is configured on a new server it always generates a public and private key for the server, just like you did for your user.
Procedure: You can generate known_host file by two methods.
- By Command prompt/Cygwin(tool).
- By Cloud Platform Integration.
In my case I will explain step by step solution through Command Prompt, as you same we have to follow it for Cygwin and after that I will explain you through Cloud Integration.
- Command Prompt:
- Install OpenSSHD
- Start menu -> run -> cmd -> ssh –V (for checking successful installation of OpenSSHD).
- Run Command -> ssh-keyscan –t rsa host_url/ip_address -> file name.
- The file will be generated.(as mentioned path. example: I navigated it to the D: drive)
PFB the snapshot, Command Prompt screen should be like this:
Note: If you are generating known_host file for your internal server then it can create it with this procedure, because in my case I was creating it for third party SFTP and I was able to generate known_host file but it was creating blank. If your file is creating blank follow Procedure 2.
- Cloud Platform Integration:
- Open Cloud Platform Integration (tenant) through S user Id and Password.
- After Logged In Navigate to -> Monitoring -> Connectivity test.
- Select SSH Connectivity test PFB,
4) Enter the following SFTP Host URL and test it and Authentication is none and Click Send.
5) You will receive the Success Response, Click on the Copy Host Key.
6) Host Key will be copied to your clipboard, create a text file, paste that copied host key into text file.
7) Rename the file and remove its extension .txt.
8) Yes, this is now your known_host file.
Hope it helps!
Thanks!
Pravesh Shukla
Good one using the built in connectivity check 🙂 I may add that the ones running Windows 10 with an appropriate version may also use WLX (Linux Subsystem) to query for the RSA Keys via "ssh-keyscan". See here how to get it https://msdn.microsoft.com/en-us/commandline/wsl/install-win10
Thanks Jens 🙂
Hi Jens,
We have used the 2nd approach in CPI to get the host key for SFTP server. But we are receiving an below error.
com.jcraft.jsch.JSchException: timeout: socket is not established
Can you please help?
Hi Rajni.
This error states that there is something wrong with the connection.
Please make sure host URL will be correct and accessible.
Regards,
Pravesh Shukla
Hi Rajni,
I am also getting the same error.Can you please help me how you resolved this?
Thanks,
Sailaja.Battula
Where to upload this known hosts file now?