password to SSH option reset for linux

arun kumar 71 Reputation points
2021-08-09T09:31:47.957+00:00

Hi Team

i had changed password option to SSH option for login to the VM in the azure portal. after that both the SSH and password options are working to login VM.

i can't able to stop VM, please help me with the steps for removing the password login option to VM.

Regards
Arun C V

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,466 questions
{count} votes

1 answer

Sort by: Most helpful
  1. vipullag-MSFT 25,611 Reputation points
    2021-08-10T06:04:41.233+00:00

    @arun kumar

    I tried your scenario in my lab environment and it is working as expected without any issues. I was able to stop the VM without any issues.

    Below are the steps that you need to do to disable password auth in Linux VM.

    Now, you have both ssh and password auth methods enabled on you VM.
    In the below screenshot you see the 2 types of logins.

    121856-l1.jpg

    Once you are logged into the VM with ssh keys, use below command and modify the file sshd_config to make changes for two parameters PasswordAuthentication and PubkeyAuthentication to no and yes respectively as shown in below screenshot.

    sudo vi /etc/ssh/sshd_config  
    

    121872-l3.jpg

    Restart the ssh service with below command

     sudo systemctl reload ssh  
    

    With this you will now be able to login to VM only with SSH keys.

    Hope this helps.

    Please 'Accept as answer' if the provided information is helpful, so that it can help others in the community looking for help on similar topics.

    0 comments No comments