question

Leojangh-9228 avatar image
0 Votes"
Leojangh-9228 asked prmanhas-MSFT commented

I can't connect my Azure VM via SSH

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

prmanhas-MSFT avatar image
0 Votes"
prmanhas-MSFT answered prmanhas-MSFT commented

@Leojangh-9228 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.






· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you for your answer,but now I have no way to connect to the shell of my VM to execute those commands. I want to know if there are other ways to connect such as through Azure Cloud Shell or the Azure web control panel, so that I can execute those recovery operations. Thank you very much.

0 Votes 0 ·

@Leojangh-9228 Currently the only way I can think of is that if any root user can do a switch to that account with Su command.

If not I would recommend you to open a Support Request with our Tech Support if you have a Support Plan in place if not let me know I can help you to enable One Time Free Technical Support.

Hope it helps!!!

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



0 Votes 0 ·

oh no it seems thath I can only discard it and create a new VM .Fortunately, it won’t cause much damage, but I need to redeploy my project and do so much configurations.That is really the story of a stupid student.Thanks have a nice day.

0 Votes 0 ·
Show more comments

I have figured it out easily yeah the Azure web control panel can reset my password just at the bottom of VM dashboard. Incredible :)

0 Votes 0 ·

@Leojangh-9228 Apologies that I missed on this detail but really Glad to hear that your issue is resolved :)

Thanks

0 Votes 0 ·