Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Mit Secure Copy (SCP) können Sie Dateien über die Befehlszeile auf Google Distributed Cloud-VM-Instanzen (Air-Gap) übertragen.
Hinweise
Sie benötigen Folgendes, um Dateien mit dem SCP-Befehlszeilentool auf VMs zu übertragen:
Sie müssen Ihre SSH-Schlüssel manuell verwalten.
Sie müssen eingehenden Traffic auf Port 22 für Ihre VM aktivieren. Weitere Informationen finden Sie auf der Seite IP-Adressen aktivieren.
Das SCP-Tool verwendet die gleichen Schlüsseldateien, die für die Herstellung einer Verbindung zu Ihren Instanzen mit Standard-SSH verwendet werden.
Berechtigungen und Zugriff anfordern
Zum Ausführen der auf dieser Seite aufgeführten Aufgaben benötigen Sie die Rolle „ProjectVirtualMachine Admin“. Prüfen Sie, ob Sie die Rolle „Project VirtualMachine Admin“ (project-vm-admin) im Namespace des Projekts haben, in dem sich die VM befindet.
Dateien auf VMs übertragen
Suchen Sie die externe IP-Adresse der VM, an die Sie Dateien senden möchten, anhand der Anleitung auf der Seite IP-Adressen aktivieren.
Im folgenden Beispiel wird das SCP-Tool verwendet, um eine Datei von Ihrer Workstation in das Basisverzeichnis der Ziel-VM zu kopieren. Dabei wird ein privater Schlüssel unter ~/.ssh/my-ssh-key verwendet:
Verwenden Sie die folgenden Definitionen für Ihre Variablen.
Variable
Definition
LOCAL_FILE_PATH
Der Name der lokalen Datei, die Sie hochladen möchten.
USERNAME
Ihr Nutzername.
IP_ADDRESS
Die externe Ingress-IP-Adresse der VM.
Dateien von einer VM übertragen
Wenn Sie Dateien von einer VM auf Ihre lokale Workstation kopieren möchten, kehren Sie die Quell- und Zielvariablen um. Im folgenden Beispiel wird gezeigt, wie Sie eine Datei von Ihrer VM in einen Pfad auf Ihrer Workstation kopieren:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[[["\u003cp\u003eSCP (secure copy) is used to transfer files to and from Google Distributed Cloud air-gapped virtual machine (VM) instances via the command line.\u003c/p\u003e\n"],["\u003cp\u003eTo use SCP, you must have access management enabled, manually manage your SSH keys, and enable ingress on port 22 for your VM.\u003c/p\u003e\n"],["\u003cp\u003eTransfer files to a VM by using the SCP command \u003ccode\u003escp -i ~/.ssh/my-ssh-key LOCAL_FILE_PATH USERNAME@IP_ADDRESS:~\u003c/code\u003e, replacing the variables with your file path, username, and the VM's external IP.\u003c/p\u003e\n"],["\u003cp\u003eTransfer files from a VM to your workstation using the SCP command \u003ccode\u003escp -i ~/.ssh/my-ssh-key USERNAME@IP_ADDRESS:REMOTE_FILE_PATH LOCAL_FILE_PATH\u003c/code\u003e, replacing variables with your credentials and file paths.\u003c/p\u003e\n"],["\u003cp\u003eYou must have the Project VirtualMachine Admin role to perform file transfer tasks to VMs.\u003c/p\u003e\n"]]],[],null,["# Transfer files\n\nUse secure copy (SCP) from the command line to transfer files to\nGoogle Distributed Cloud air-gapped virtual machine (VM) instances.\n\nBefore you begin\n----------------\n\n| **Important:** You *must already have access management enabled* to proceed. If you do not, follow the steps in [Guest environment](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/manage-the-os/guest-environment). By default, access management is enabled.\nYou need the following to use the SCP command-line tool to transfer files to VMs:\n\n- You must manually manage your SSH keys.\n- You must enable ingress on port 22 for your VM. See the [Enable IP addresses](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/connect-to-vm/ip-addresses) page for more information.\n\nThe SCP tool uses the same key files that you use to connect to your instances\nusing standard SSH.\n| **Important:** If you haven't yet applied a public key to your VM instance, create an SSH key pair and add the public key to the VM following the instructions in [Linux (SSH)](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/connect-to-vm/connect-to-a-vm#api).\n\n### Request permissions and access\n\nTo perform the tasks listed in this page, you must have the Project\nVirtualMachine Admin role. Follow the steps to\n[verify](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/preparation#verify-user-access)\nthat you have the Project VirtualMachine Admin (`project-vm-admin`) role in the namespace\nof the project where the VM resides.\n\nTransfer files to VMs\n---------------------\n\nLocate the external IP address for the VM to which you want to send files using\nthe instructions on the [Enable IP addresses](/distributed-cloud/hosted/docs/latest/gdch/application/ao-user/vms/connect-to-vm/ip-addresses)\npage.\n\nUse the SCP tool to copy a file from your workstation to the home directory of\nthe target VM in the following example, which uses a private key at\n`~/.ssh/my-ssh-key`: \n\n scp -i ~/.ssh/my-ssh-key \u003cvar translate=\"no\"\u003eLOCAL_FILE_PATH\u003c/var\u003e \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e@\u003cvar translate=\"no\"\u003eIP_ADDRESS\u003c/var\u003e:~\n\nUse the following definitions for your variables.\n\nTransfer files from a VM\n------------------------\n\nTo copy files from a VM to your local workstation, reverse the source and\ndestination variables. The following example shows how to copy a file from your\nVM to a path on your workstation: \n\n scp -i ~/.ssh/my-ssh-key \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e@\u003cvar translate=\"no\"\u003eIP_ADDRESS\u003c/var\u003e:\u003cvar translate=\"no\"\u003eREMOTE_FILE_PATH\u003c/var\u003e \u003cvar translate=\"no\"\u003eLOCAL_FILE_PATH\u003c/var\u003e\n\nUse the following definitions for your variables."]]