skip to Main Content

What I want to do:

  • I want to make an SSH connection and log in to Linux, which was created using Azure, as a user named testuser.

Problem:

  • I get the following error when I run the ssh command.
C:Usersavduser>ssh testuser@<IP address>
testuser@<IP address>: Permission denied(publickey).
  • /var/log/auth.log
Connection reset by authenticating user testuser <IP address> port <portNum> [preauth]

**I tried: **

  • change /etc/ssh/sshd_config
PasswordAuthentication yes
  • service restart: systemctl restart sshd
  • virtial Machine restart: reboot

I don’t have any other ideas to try.
Thank you

2

Answers


  1. Chosen as BEST ANSWER

    I also had to change in /etc/ssh/sshd_config

    KbdInteractiveAuthentication yes
    

    Thank you.


  2. Given the steps you’ve already taken and the persistent issue, let’s explore additional solutions and troubleshooting steps to resolve the Permission denied (publickey) error when trying to SSH into your Linux VM in Azure as testuser. I feel it has something to do with the pem keys. However better to verify all the other aspects as well.
    Open /etc/ssh/sshd_config and confirm there’s only one PasswordAuthentication yes directive and it’s not commented out. After making changes, remember to restart the SSH service (sudo systemctl restart sshd). Ensure the testuser exists and has a valid password set. Having said that.

    In order to login to a linux machine on azure there are two ways-

    1. using SSH
    2. Using password

    Using SSH-
    Create your Linux VM as usual on Azure.
    enter image description here

    Just select SSH public key. As go proceed, Azure will prompt you to download this pem key which you just created. Download and save it to your desired location and continue to complete the setup process. Once the VM is ready, go to resource and connect.
    enter image description here
    Post validation, it will ask you to connect. Now it’s your choice if you want to connect via azure cli or your own native ssh for example powershell. Here just do
    ssh -i ~/<yourpath-where-you-downloaded-the-pemfile>/<Your-Key-Name.pem> <username>@20.127.229.58enter image description here

    Second option, using password.
    Same process as above just during creation select password instead of ssh and give your preferred password.
    enter image description here

    Rest of the configuration will remain same, but here azure won’t prompt you for downloading the pem key as you have set password. Just connect once the system is ready.
    Do a su <username>
    enter image description here

    Reference:
    MS Doc

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search