Skip to main content

Azure SSH and File Transfer using SCP

SSH Connectivity

To connect via SSH to an Azure Linux VM, use the following PowerShell command substituting the IP address:

az ssh vm --ip <IP Address>

Transfer files using SCP

To transfer files using the command line tool SCP, we must first create public encryption keys which are only valid for 1 hour at a time using the following PowerShell commands:

az ssh config --ip * --file ~/azure-sshconfig --keys-destination-folder ~/azure-keys

This will create the public encryption keys to the user's home folder as a file named azure-keys.

Next, to transfer files from the remote VM to the local computer, use the following PowerShell command substituting the IP/Host, file path, and local destination path:

scp -F ~/azure-sshconfig <IP Address/Hostname>:<Remote File Path> <Local File Path>

For instance, if you wanted to copy Ignition's wrapper log files to the local folder you'd use the following command:

scp -F ~/azure-sshconfig <IP Address/Hostname>:/usr/local/bin/ignition/logs/wrapper.log* .

To transfer files from the local computer to the remote VM , use the following PowerShell command substituting the IP/Host, local file path, and remote destination path:

scp -F ~/azure-sshconfig <Local File Path> <IP Address/Hostname>:<Remote File Path>

To do a recursive copy of an entire folder and it's subfolders, add the -R option in front of the -F option.

As a security measure, you should always delete the encryption keys when finished with the following PowerShell command:

del ~/azure-sshconfig