Conéctate a VMs de Linux mediante Cloud VPN o Cloud Interconnect
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Linux
En este documento, se describe cómo conectarse a una instancia de máquina virtual (VM) a través de su dirección IP interna desde una red local que usa Cloud VPN o Cloud Interconnect para conectarte a la red de VPC de la VM.
Conectarte a una VM mediante su dirección IP interna es útil si la VM no tiene una dirección IP externa. Si la VM tiene una dirección IP externa, conéctate a la VM mediante su dirección IP externa.
Si tu red local no está conectada a la red de VPC de tu VM y necesitas conectarte a la dirección IP interna de la VM, revisa los otros métodos que se mencionan en Opciones de conexión para VMs de uso interno exclusivo.
Sistemas operativos compatibles
Estos métodos de conexión son compatibles con todas las imágenes públicas de Linux que están disponibles en Compute Engine. Para imágenes de Fedora CoreOS, debes
configurar el acceso SSH
antes de poder usar estos métodos.
Conéctate a las VM
Para conectarte a una VM, completa los pasos en una de las siguientes pestañas.
At the bottom of the Google Cloud console, a
Cloud Shell
session starts and displays a command-line prompt. Cloud Shell is a shell environment
with the Google Cloud CLI
already installed and with values already set for
your current project. It can take a few seconds for the session to initialize.
Conéctate a la VM mediante la ejecución del siguiente comando:
gcloud compute ssh VM-NAME \
--internal-ip
Reemplaza VM_NAME por el nombre de la VM a la que te quieres conectar.
IAP Desktop
Para conectarte a una VM mediante IAP Desktop, haz lo siguiente:
Abre IAP Desktop. Se abrirá la ventana Agregar proyectos.
Cuando se te solicite, accede con la Cuenta de Google que tiene acceso al proyecto con las VMs a las que deseas conectarte.
En la ventana Agregar proyectos, ingresa el nombre o el ID del proyecto que contiene las VMs a las que deseas conectarte.
En la ventana Explorador de proyectos, haz clic con el botón derecho en el nombre de la VM a la que deseas conectarte y selecciona Configuración de conexión.
En la ventana Connection settings, establece Connect via en Vpc.
En la ventana Explorador de proyectos, haz clic con el botón derecho en el nombre de la VM y selecciona Conectar para conectarte a la VM.
Clientes OpenSSH
Para conectarte a la dirección IP interna de una VM desde un cliente de OpenSSH, haz lo siguiente:
Para conectarte a la
VM, ejecuta el siguiente comando:
ssh -i PATH_TO_PRIVATE_KEYUSERNAME@INTERNAL_IP
Reemplaza lo siguiente:
PATH_TO_PRIVATE_KEY: la ruta al archivo de clave SSH privada que corresponde a la clave pública que agregaste a la VM.
USERNAME:
Tu
nombre de usuario. Si administras las claves SSH en
metadatos, el nombre de usuario es el que especificaste cuando
creaste la clave SSH.
En
el caso de las
cuentas de Acceso al SO, el nombre de usuario se
define en tu perfil de Google.
Por ejemplo, cloudysanfrancisco_example_com o cloudysanfrancisco.
INTERNAL_IP es la dirección IP interna de la VM.
App de PuTTY
Para conectarte a través de la dirección IP interna de una VM mediante PuTTY, haz lo siguiente:
Abre la app de PuTTY. Se abrirá una ventana de configuración de conexión.
En el campo Host Name, ingresa el nombre de usuario asociado con la clave SSH y la dirección IP interna de la VM a la que te quieres conectar. Usa el siguiente formato:
USERNAME@INTERNAL_IP
Reemplaza lo siguiente:
USERNAME:
Tu
nombre de usuario. Si administras las claves SSH en
metadatos, el nombre de usuario es el que especificaste cuando
creaste la clave SSH.
En el caso de las
cuentas de Acceso al SO, el nombre de usuario se
define en tu perfil de Google.
Por ejemplo, cloudysanfrancisco_example_com o cloudysanfrancisco.
INTERNAL_IP es la dirección IP interna de la VM.
En el menú Categoría, navega hasta Conexión > SSH > Auth.
En el campo Archivo de claves privadas para la autenticación, selecciona el archivo de clave SSH privada que corresponde a la clave pública que agregaste a la VM.
Haz clic en Abrir para conectarte a la VM.
Soluciona problemas
Si deseas encontrar métodos para diagnosticar y resolver conexiones SSH fallidas, consulta Soluciona problemas de SSH.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[[["\u003cp\u003eThis guide outlines methods for connecting to a Linux virtual machine (VM) using its internal IP address, specifically from an on-premises network linked via Cloud VPN or Cloud Interconnect.\u003c/p\u003e\n"],["\u003cp\u003eConnecting via internal IP is particularly useful when the VM lacks an external IP address, though alternative connection methods exist for internal-only VMs.\u003c/p\u003e\n"],["\u003cp\u003eThe document supports connections to all public Linux images available on Compute Engine, and details connection methods using gcloud, IAP Desktop, OpenSSH clients, and PuTTY.\u003c/p\u003e\n"],["\u003cp\u003eThe guide provides instructions on how to initiate SSH connections using various methods, including command-line tools and graphical interfaces.\u003c/p\u003e\n"],["\u003cp\u003eTroubleshooting resources are available to help resolve any issues that may occur when connecting via SSH to a VM.\u003c/p\u003e\n"]]],[],null,["# Connect to Linux VMs using Cloud VPN or Cloud Interconnect\n\nLinux\n\n*** ** * ** ***\n\nThis document describes how to connect to a virtual machine (VM) instance\nthrough its internal IP address, from an on-premises network that uses\n[Cloud VPN](/network-connectivity/docs/vpn/concepts/overview) or\n[Cloud Interconnect](/network-connectivity/docs/interconnect/concepts/overview)\nto connect to the VM's VPC network.\n\nConnecting to a VM using its internal IP address is useful if the VM doesn't\nhave an external IP address. If the VM does have an external IP address,\n[connect to the VM using its external IP address](/compute/docs/instances/connecting-to-instance).\nIf your on-premises network isn't connected to your VM's VPC\nnetwork and you need to connect to your VM's internal IP address, review the\nother methods listed in\n[Connection options for internal-only VMs](/compute/docs/connect/ssh-internal-ip).\n\nSupported operating systems\n---------------------------\n\nThese connection methods are supported for all\n[public Linux images](/compute/docs/images/os-details) that are available on\nCompute Engine. For Fedora CoreOS images, you must\n[set up SSH access](https://docs.fedoraproject.org/en-US/fedora-coreos/tutorial-containers/)\nbefore you can use these methods.\n\nConnect to VMs\n--------------\n\nTo connect to a VM, complete the steps in one of the following tabs. \n\n### gcloud\n\nConnect to a VM using SSH by running the\n[`gcloud compute ssh` command](/sdk/gcloud/reference/compute/ssh) with the\n[`--internal-ip` flag](/sdk/gcloud/reference/compute/ssh#--internal-ip):\n\n1. In the Google Cloud console, activate Cloud Shell.\n\n [Activate Cloud Shell](https://console.cloud.google.com/?cloudshell=true)\n\n\n At the bottom of the Google Cloud console, a\n [Cloud Shell](/shell/docs/how-cloud-shell-works)\n session starts and displays a command-line prompt. Cloud Shell is a shell environment\n with the Google Cloud CLI\n already installed and with values already set for\n your current project. It can take a few seconds for the session to initialize.\n2. Connect to the VM by running the following command:\n\n ```\n gcloud compute ssh VM-NAME \\\n --internal-ip\n ```\n3. Replace \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of the VM that you want to connect to.\n\n| **Note:** When you connect to VMs using the gcloud CLI, Compute Engine creates a persistent SSH key for you. For more information about SSH keys, see [SSH connections to Linux VMs](/compute/docs/instances/ssh).\n\n### IAP Desktop\n\nTo connect to a VM using IAP Desktop, do the following:\n\n1.\n [Install IAP Desktop](https://github.com/GoogleCloudPlatform/iap-desktop/)\n on your workstation if you haven't already.\n\n2.\n Open IAP Desktop. The **Add projects** window opens.\n\n3.\n\n When prompted, sign in using the Google account that has access to the project with the VMs\n you want to connect to.\n\n4.\n In the **Add projects** window, enter the project ID or name of the\n project that contains the VMs you want to connect to.\n\n5.\n In the **Project Explorer** window, right-click the name of the VM that\n you want to connect to and select **Connection settings**.\n\n6.\n In the **Connection settings** window, set **Connect via**\n to **Vpc**.\n\n7.\n In the **Project Explorer** window, right-click the name of the VM\n again and select **Connect** to connect to the VM.\n\n### OpenSSH clients\n\nConnect through a VM's internal IP address from an OpenSSH client, by doing the following:\n\n1. [Add an SSH key to the VM](/compute/docs/connect/add-ssh-keys) if you haven't already.\n2. In the Google Cloud console, go to the **VM Instances** page and find the\n\n internal IP address\n\n of the\n\n VM that you want to connect to.\n\n [Go to VM Instances](https://console.cloud.google.com/compute/instances)\n3. Open a terminal on your workstation.\n4. Connect to the\n\n VM by running the following command:\n\n ```\n ssh -i PATH_TO_PRIVATE_KEY USERNAME@INTERNAL_IP\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePATH_TO_PRIVATE_KEY\u003c/var\u003e: the path to the private SSH key file that corresponds to the public key you added to the VM.\n - \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e: your username. If you manage your SSH keys in metadata, the username is what you specified when you [created the SSH key](/compute/docs/connect/create-ssh-keys). For OS Login accounts, the username is [defined in your Google profile](/compute/docs/connect/add-ssh-keys#os-login). For example, `cloudysanfrancisco_example_com` or `cloudysanfrancisco`.\n - \u003cvar translate=\"no\"\u003eINTERNAL_IP\u003c/var\u003e: the internal IP address of the VM.\n\n### PuTTY app\n\nConnect through a VM's internal IP address using PuTTY, by doing the following:\n\n1. [Add an SSH key](/compute/docs/connect/add-ssh-keys) to the VM if you haven't already.\n2. If your workstation doesn't already have the PuTTY app installed, [download the PuTTY package files](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html).\n3. In the Google Cloud console, go to the **VM Instances** page and find the\n\n internal IP address\n\n of the VM that you want to connect to.\n\n [Go to VM Instances](https://console.cloud.google.com/compute/instances)\n4. Open the PuTTY app. A connection configuration window opens.\n5. In the `Host Name` field, enter the username associated with the SSH key, and\n the\n\n internal IP address\n\n of the VM that you want to connect to. Use the following format:\n\n ```\n USERNAME@INTERNAL_IP\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e: your username. If you manage your SSH keys in metadata, the username is what you specified when you [created the SSH key](/compute/docs/connect/create-ssh-keys). For OS Login accounts, the username is [defined in your Google profile](/compute/docs/connect/add-ssh-keys#os-login). For example, `cloudysanfrancisco_example_com` or `cloudysanfrancisco`.\n - \u003cvar translate=\"no\"\u003eINTERNAL_IP\u003c/var\u003e: the internal IP address of the VM.\n6. In the **Category** menu, navigate to **Connection \\\u003e\n SSH \\\u003e Auth**.\n7. In the **Private key file for authentication** field, select the private SSH key file that corresponds to the public key you added to the VM.\n8. Click **Open** to connect to the VM.\n\nTroubleshooting\n---------------\n\nTo find methods for diagnosing and resolving failed SSH connections, see\n[Troubleshooting SSH](/compute/docs/troubleshooting/troubleshooting-ssh).\n\nWhat's next\n-----------\n\n- Learn how to [manage access to VMs](/compute/docs/instances/access-overview).\n- Learn how to [transfer files to VMs](/compute/docs/instances/transfer-files).\n- Learn how [SSH connections to Linux VMs](/compute/docs/instances/ssh) work on Compute Engine."]]