Use the -F flag to tell scp to use that configuration: scp -F vagrant_ssh_config default:/path/to/file.txt ./
For those who prefer a GUI, once you have identified the SSH port and private key, you can also use tools like WinSCP or FileZilla to connect and download files visually. How to copy file from a Vagrant machine to localhost
If you need a custom sync location, you can define it in your Vagrantfile using the following HashiCorp Documentation syntax:
Alternatively, you can manually target the default forwarded port (usually ) and use the private key found in .vagrant/machines/default/virtualbox/private_key : scp -P 2222 -i .vagrant/machines/default/virtualbox/private_key vagrant@127.0.0.1:/remote/path/file.txt ./local/path/ 4. Summary of Transfer Methods Prerequisite Synced Folders Frequent transfers Enabled by default vagrant-scp Simple CLI usage vagrant-scp plugin Manual SCP One-off transfers SSH access/Private key Python Server Quick browser access Python installed on VM
config.vm.synced_folder "relative/path/on/host", "/path/on/guest" Use code with caution. 2. Using the vagrant-scp Plugin
If you don't want to install plugins, you can use the standard scp command by leveraging Vagrant's auto-generated SSH configuration.
vagrant scp [vm_name]:/path/to/remote/file.txt ./local_destination.txt 3. Using Native scp with SSH Config