title: ESXi keeps prompting for password after adding ssh public key to authorized_keys
body: <p>I want to add my ssh public key to the ESXi 7 host, so that I can login via ssh without using password.</p>
  <p>But the esx host keep prompting me for the password.</p>
  <p>I have tried the following:</p>
  <h1>Scenario A</h1>
  <p><strong>When using the &quot;normal&quot; way of adding ssh keys to a host.</strong></p>
  <ol>
  <li>Make a ssh key pair with <code>ssh-keygen -t rsa</code></li>
  <li>Push ssh public key to ESXi host with <code>ssh-copy-id root@esx.host</code></li>
  <li>Now try login to esx host using <code>ssh root@esx.host</code></li>
  </ol>
  <p>This will prompt you for a password again.</p>
  <p><strong>Reason for failing</strong></p>
  <p>The ssh key is added to the esx hosts <code>~/.ssh/authorized_keys</code> - but the SSH service, expect to find the keys in <code>/etc/ssh/keys-root/authorized_keys</code>.</p>
  <h1>Scenario B</h1>
  <p><strong>Adding the the right place</strong></p>
  <ol>
  <li>Copy the key into esx by <code>cat ~/.ssh/id_rsa.pub | ssh root@esx.host 'cat &gt;&gt;/etc/ssh/keys-root/authorized_keys'</code></li>
  <li>Try login again with <code>ssh root@esx.host</code></li>
  </ol>
  <p>Still asking for password.</p>