Help Center/ ModelArts/ Troubleshooting/ DevEnviron/ SSH Faults/ SSH Cannot Be Used and the Error "Permission denied (publickey)" Is Displayed After the Permission on the /home/ma-user/.ssh Directory Is Changed
Updated on 2025-11-18 GMT+08:00

SSH Cannot Be Used and the Error "Permission denied (publickey)" Is Displayed After the Permission on the /home/ma-user/.ssh Directory Is Changed

Symptom

The permissions on the /home/ma-user/.ssh directory were changed. As a result, the notebook instance could not be connected using SSH, and the following error was displayed:

Permission denied (publickey)
Figure 1 Error message example

Possible Causes

The permissions on the /home/ma-user and SSH directories on the server are incorrect. The following figure shows an example of incorrect permissions.

Solution

You can use either of these methods to solve the problem:

  • Delete the /home/ma-user/.ssh directory when creating the image. You do not need to set up SSH; it is automatically generated when the notebook starts.
  • Run the following commands to change the permission on the .ssh file:
    # Set the permission on the /home/ma-user directory to 750.
    chmod 750 /home/ma-user
    
    chmod 750 ~/.ssh
    chmod 644 ~/.ssh/authorized_keys
    chmod 640 ~/.ssh/environment
    chmod 750 ~/.ssh/etc
    chmod 640 ~/.ssh/known_hosts
    chmod 750 ~/.ssh/var
    chmod 600 ~/.ssh/etc/ssh_host_rsa_key
    chmod 640 ~/.ssh/etc/ssh_host_rsa_key.pub
    chmod 750 ~/.ssh/etc/sshd_config
    chmod 750 ~/.ssh/var/run/sshd.pid