32 ‐ Use Case SSH Password Authentication Not Working on OCI Instance - SanjeevOCI/Study GitHub Wiki

Use Case: SSH Password Authentication Not Working on OCI Instance

Issue

Unable to log in via SSH using password authentication for root or opc users on an OCI instance.
SSH only offers public key authentication, even after enabling PasswordAuthentication yes and PermitRootLogin yes in /etc/ssh/sshd_config.


Root Cause

A config file (/etc/ssh/sshd_config.d/50-cloud-init.conf) contained PasswordAuthentication no, which overrides the main SSH config and disables password login.


Resolution Steps

  1. Edit /etc/ssh/sshd_config.d/50-cloud-init.conf and set:

    PasswordAuthentication yes
    

    (or comment out the line)

  2. Ensure main /etc/ssh/sshd_config has:

    PermitRootLogin yes
    PasswordAuthentication yes
    AllowUsers root opc
    UsePAM yes
    
  3. Restart SSHD:

    sudo systemctl restart sshd
    
  4. Test SSH login with password.

    ssh [email protected]
    ssh [email protected]
    

Result

Password authentication for root and opc works as expected.