I can't connect my Azure VM via SSH

Leojangh 21 Reputation points
2021-04-13T06:13:49.547+00:00

I just replaced my user uid from 1000 to 0 in the file://etc/passwd.I connected to my VM via SSH with my SSH key previously,but now it show "Permission denied (pulbickey)".The result is I cant connect it because I dont konw whether there are alternative methods to connect ,or how to fix it?.Thanks!

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

Accepted answer
  1. prmanhas-MSFT 17,901 Reputation points Microsoft Employee
    2021-04-14T10:37:56.977+00:00

    @Leojangh Apologies for the delay in response and all the inconvenience caused because of the issue.

    Changing a users uid affects its ability to ssh and is not recommended as a best practice. Do not edit /etc/passwd file by hand or using a text editor such as vi. This explains how to change or rename username in Linux using the usermod command.

    As per mentioned in the article you might need to change the entry in password files and then remove their home folded of the user and need to change password of the user. Now since the key pair is stored under the user profile you will need to do the key pair copy again since you wont be able to use the old ssh key pair.

    You can use ssh-copy-id command for same. Once done you should be able to SSH to your VM.

    Hope it helps!!!

    Please "Accept as Answer" if it helped so it can help others in community looking for help on similar topics.

    Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as convenient to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.