Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
All solutions
    • All solutions for Compute Cloud
    • You are unable to add a committed volume of services (CVoS) for Compute Cloud
    • Resolving the `Permission denied` error when connecting to a VM created with Terraform
    • Nested virtualization is not supported
    • Fixing the "Not enough resources" error on launching a virtual machine
    • Recovering access to a VM with a lost SSH key
    • Resolving issues with creating disk snapshots
    • Boot disk size failed to increase
    • VM shuts down on the `Instance guest stop processing` operation
    • Resolving the `WARNING REMOTE HOST IDENTIFICATION HAS CHANGED` error
    • Fixing a non-replicated disk failure
    • Resolving connection issues with Kosmos VM
    • Resolving password reset issues for VMs based on a Kosmos image
    • Resolving the `The limit on maximum number of cores has exceeded` error
    • CUDA unavailable on GPU platform
    • Resolving issues with performance of disk and network input/output on a VM
    • Resolving the `FAILED_PRECONDITION Relocation to zone `ru-central1-a/b/c` is disabled` error
    • Options to migrate a VM image to Yandex Cloud
    • How to change a boot disk type for a VM
    • How to get details about RAM consumption for Compute Cloud VMs
    • How to create VMs with multiple network interfaces
    • How to reduce the VM disk size
    • How to export Compute Cloud VM disk images
    • How to move a VM across folders or clouds
    • How to set up GUI and graphical environment on VMs running Linux
    • How to use an ISO image for deploying VMs
    • How to view incoming or outgoing traffic logs for a VM
    • How to use WinSCP to connect to a Linux VM in Yandex Cloud with a key generated on VM creation
    • How to back up a VM with rollback support
    • How to connect over SSH as root with `-X` or key
    • How to monitor memory usage
    • How to change an internal IP address
    • How to read the `Connections quota utilization` chart
    • How to check the disk access speed for a VM
    • How to create a VM instance with password access
    • How to increase the number of network connections
    • How to secure RDP connections on Microsoft Windows®

In this article:

  • Issue description
  • Solution
  1. Compute Cloud
  2. Resolving the `Permission denied` error when connecting to a VM created with Terraform

Resolving the Permission denied error when connecting to a VM created with Terraform

Written by
Yandex Cloud
Updated at December 17, 2025
  • Issue description
  • Solution

Issue descriptionIssue description

Trying to connect to a VM over SSH after creating that VM using Terraform returns the Permission denied error.

SolutionSolution

If you provide a key within ssh-keys, the text specified in the SSH key comment will not be processed. As a result, the key will be assigned to the user set as default in the cloud-init configuration for this image.

Note

Such a username might vary across VM images. For more information on this, see this article.

If you need to add a user with a specific name when creating your VM, provide the user metadata file as a cloud-init-compatible YAML, adding the metadata file path to the Terraform manifest:

  1. Create a UTF-8-encoded text file with the following contents:

    #cloud-config
    users:
      - name: <username>
        groups: sudo
        shell: /bin/bash
        sudo: 'ALL=(ALL) NOPASSWD:ALL'
        ssh_authorized_keys:
          - ssh-ed25519 AAAAB3Nza......OjbSMRX user@example.com
          - ssh-ed25519 AAAAB3Nza......Pu00jRN user@desktop
    
  2. In the metadata section inside your Terraform manifest, specify the following:

    metadata = {
        user-data = "${file("<file_path>")}"
    }
    

You can look up the details about the user and the key in the serial port output for the created VM. If the SSH key is valid, the output should include the following:

ci-info: ++++++++++++++++++++++++++++++++++++++Authorized keys from /home/test/.ssh/authorized_keys for user ubuntu++++++++++++++++++++++++++++++++++++
ci-info: +---------+-------------------------------------------------------------------------------------------------+---------+----------------------+
ci-info: | Keytype |                                       Fingerprint (sha256)                                      | Options |       Comment        |
ci-info: +---------+-------------------------------------------------------------------------------------------------+---------+----------------------+
ci-info: | ssh-rsa | 7f:fa:ab:5c:b5:67:6b:4a:65:1e:65:bb:93:13:0b:0b:d2:06:52:63:bf:ed:c6:16:4d:55:b6:fb:c5:a2:30:f0 |    -    | some_text            |
ci-info: +---------+-------------------------------------------------------------------------------------------------+---------+----------------------+

Where ubuntu is the username, and ssh-rsa is the SSH key fingerprint.

Alert

The serial output containing this data is available after the VM is created and until it restarts for the first time.

Was the article helpful?

Previous
You are unable to add a committed volume of services (CVoS) for Compute Cloud
Next
Nested virtualization is not supported
© 2026 Direct Cursus Technology L.L.C.