Hello @Mubashir P ,
Welcome to the MS Q&A forum.
Are you not able to ssh only while using one specific method? Can you connect by using any other way? What error message are you getting? Were able to ssh before?
Please, check that Detailed SSH troubleshooting steps for issues connecting to a Linux VM in Azure post. There is a really good explanation and steps how to identify the source of the issue.
As additional, please kindly review these public posts on SSH troubleshooting, and if this is a new deployment for you, please quickly review the learn content on how to deploy and connect to a running VM using SSH.
-----------------------------------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards,
Olga