The first thing to do in this situation is to use the -v
option to ssh
, so you can see what types of authentication is tried and what the result is. Does that help enlighten the situation?
In your update to your question, you mention "on another local Ubuntu". Have you copied over the ssh private key to the other machine?
Don't use a password. Generate a passphrase-less SSH key and push it to your VM.
If you already have an SSH key, you can skip this step…
Just hit Enter for the key and both passphrases:
$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.
Copy your keys to the target server:
$ ssh-copy-id id@server
id@server's password:
Now try logging into the machine, with ssh 'id@server'
, and check-in:
.ssh/authorized_keys
Note: If you don't have .ssh dir and authorized_keys file, you need to create it first
to make sure we haven’t added extra keys that you weren’t expecting.
Finally, check to log in…
$ ssh id@server
id@server:~$
You may also want to look into using ssh-agent
if you want to try keeping your keys protected with a passphrase.
Best Answer
You need to enable password authentication first before setting a user password. To do that:
/etc/ssh/sshd_config
as root.PasswordAuthentication
. Make sure it's uncommented and set toyes
.Now, using the following command to set the user password:
That's it! You should try to login now without the key file.