How Do I Log in to Ubuntu Machine

David Rogers 26 Reputation points
2022-02-15T23:05:14.697+00:00

A while back, I set up an Ubuntu VM.
During that setup, I downloaded a PEM file.
I was not able to log in with it and gave up in frustration.
I thought I'd try again, but now I cannot even find the PEM file.

How do I get from here, to a working SSH session on the VM?

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

Accepted answer
  1. kobulloc-MSFT 26,801 Reputation points Microsoft Employee Moderator
    2022-02-15T23:34:54.103+00:00

    Hello, @David Rogers !

    You'll want to use the Reset password feature under Support + troubleshooting in the portal to reset access to your VM (see instructions below). Once you have your PEM again, one of the more straight forward ways to connect is to use the SSH wizard in the portal which will generate a command for you based on your PEM file location:

    174607-image.png

    Reset Password: What do I do if I lose my PEM file and need to connect to my Ubuntu Virtual Machine?
    When you create a Linux virtual machine, you will be warned that Azure does not store the private key used for SSH (a copy of the public key is on the virtual machine). If you've lost the PEM file and need to connect to your virtual machine you can use the Reset Password feature in the portal under Support + troubleshooting.

    174585-image.png

    174633-image.png

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. David Rogers 26 Reputation points
    2022-02-16T04:20:56.543+00:00

    Thanks for the link about resetting the key. That seemed to work.

    Unable to log in with it though. Here is a snippet of some of the commands that I've been running (using Windows subsystem for Linux):

    dave@GOLIATH:/mnt/f/zLoad$ chmod 400 dave.pem
    dave@GOLIATH:/mnt/f/zLoad$ ssh -i ./dave.pem dave@23.99.182.143
    The authenticity of host '23.99.182.143 (23.99.182.143)' can't be established.
    ECDSA key fingerprint is SHA256:wSrOHkd9jlCIfcAt8lWDbwWPu90RsXhgFA9N2T/2byQ.
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Warning: Permanently added '23.99.182.143' (ECDSA) to the list of known hosts.
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0555 for './dave.pem' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    Load key "./dave.pem": bad permissions
    dave@23.99.182.143: Permission denied (publickey).
    dave@GOLIATH:/mnt/f/zLoad$ ls -la dave.pem
    -r-xr-xr-x 1 dave dave 3243 Feb 16 14:08 dave.pem
    dave@GOLIATH:/mnt/f/zLoad$ chmod 400 dave.pem
    dave@GOLIATH:/mnt/f/zLoad$ ssh -i ./dave.pem dave@23.99.182.143
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0555 for './dave.pem' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    Load key "./dave.pem": bad permissions
    dave@23.99.182.143: Permission denied (publickey).
    dave@GOLIATH:/mnt/f/zLoad$ ls -la dave.pem
    -r-xr-xr-x 1 dave dave 3243 Feb 16 14:08 dave.pem
    dave@GOLIATH:/mnt/f/zLoad$ ssh -i ./dave.pem azureuser@23.99.182.143
    azureuser@23.99.182.143: Permission denied (publickey).
    dave@GOLIATH:/mnt/f/zLoad$ ssh -i ./dave.pem dave@23.99.182.143
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0555 for './dave.pem' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    Load key "./dave.pem": bad permissions
    dave@23.99.182.143: Permission denied (publickey).
    

  2. David Rogers 26 Reputation points
    2022-02-17T04:23:32.863+00:00

    Thanks @Anonymous ,

    I swapped over to bash shell (git) and it worked. That's good enough.

    Appreciate the help.


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.