[SOLVED] Can't connect via Pubkey to my CentOS VM
Posted: 2019/04/01 04:21:21
Hi, I've set up a CentOS virtual machine using VMware 15 on my Windows 10 host.The idea is to be able to connect to the CentOS machine using a crypto key instead of a password.
So I powered the machine on and accessed it directly into VMware, created a .ssh dir under ~, which received the permission 700. (drwx------).
Then I opened Windows CMD on the host machine, executed ssh-keygen to generate the key pair:
Afterwards, I opened the public key (C:\Users\me\.ssh\id_rsa.pub) with a text editor and copied its contents, then, back at the console, I logged in the virtual machine again.
Next, I created the ~/.ssh/autorized_keys file, edited and pasted the contents stored on the clipboard (the key C:\Users\me\.ssh\id_rsa.pub). Chmoded ~/.ssh/autorized_keys to 600.
After that I proceeded to editing the /etc/ssh/sshd_config file, changing the following:
Then exited and tried logging in again, this time using ssh me@192.168.1.15 -i C:\Users\me\.ssh\id_rsa
Still, it keeps asking for my password.
I visited this page and performed the final step:
Still nothing. What did I miss?
p.s. this is my kernel info: Linux me 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
So I powered the machine on and accessed it directly into VMware, created a .ssh dir under ~, which received the permission 700. (drwx------).
Then I opened Windows CMD on the host machine, executed ssh-keygen to generate the key pair:
First I made sure I was the sole owner of the C:\users\me\.ssh folder; I read it could cause problems if more entities had permission to read/write/execute on that folder.C:\Users\me\.ssh\id_rsa
C:\Users\me\.ssh\id_rsa.pub
Afterwards, I opened the public key (C:\Users\me\.ssh\id_rsa.pub) with a text editor and copied its contents, then, back at the console, I logged in the virtual machine again.
Next, I created the ~/.ssh/autorized_keys file, edited and pasted the contents stored on the clipboard (the key C:\Users\me\.ssh\id_rsa.pub). Chmoded ~/.ssh/autorized_keys to 600.
After that I proceeded to editing the /etc/ssh/sshd_config file, changing the following:
Code: Select all
PubkeyAuthentication yes
PasswordAuthentication no
Still, it keeps asking for my password.
I visited this page and performed the final step:
Code: Select all
restorecon -Rv ~/.ssh
p.s. this is my kernel info: Linux me 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux