How to Copy files between ESXi hosts using SCP Command
Posted by jpluimers on 2021/05/21
Derived the bits below from [WayBack] How to Copy files between ESXi hosts using SCP Command.
Recursive copy from a remote machine to an existing local directory:
scp -rp root@192.168.71.97://vmfs/volumes/EVO860_500GB/VM1/ /vmfs/volumes/EVO860_250GB/VM2/
After this you need to edit the .vmxf
files in the VM2
directory to ensure these are not duplicates.
One thing to remember is that you need the current host to allow the SSH client in the firewall, which is disabled by default:
After enabling:
Be really careful with the -3
option to scp; it allows you to transfer from one remote machine to another remote machine, but when using keyboard-interactive, you have a high change to lock-out your accounts: SSH will try to keyboard-interactive to both hosts at the same time.
If you lock-out root, then you have to go through the local DCUI console (use ALT-F2 to go there), then reset the root account failure count using pam_tally2 --user root --reset
.
So this can be bad:
scp -3 -rp root@192.168.71.97://vmfs/volumes/EVO860_500GB/VM1/ root@192.168.71.91://vmfs/volumes/EVO860_250GB/VM2/
This works, but assumes the SSH client is enabled from the first host:
scp -rp root@192.168.71.97://vmfs/volumes/EVO860_500GB/VM1/ root@192.168.71.91://vmfs/volumes/EVO860_250GB/VM2/
See these links:
- On
scp -3
:- [WayBack] scp(1) – Linux manual page
-3 Copies between two remote hosts are transferred through the local host. Without this option the data is copied directly between the two remote hosts. Note that this option disables the progress meter.
- [WayBack] linux – scp between two remote hosts from my (third) pc – Super User
The source and target can be specified as a URI in the form scp://[user@]host[:port][/path]
so you can run:
scp -3 scp://user@10.3.0.1:22/path/to/file scp://user@10.3.0.2:6969/pa
- [WayBack] ssh – Rsync equivalent to scp -3 – Stack Overflow
- [WayBack] scp(1) – Linux manual page
- On root lockout:
- On enabling and accessing DCUI:
- [WayBack] How to access DCUI/Console of ESXi using ALT+F Keys (2148363)
After you enable the ESXi Shell in the direct console, you can use these below combination of ALT + Function keys to access the Direct Console User Interface (DCUI) of an ESXi host:
- ALT+F1 = Switches to the console.
- ALT+F2 = Switches to the DCUI.
- ALT+F11 = Returns to the banner screen.
- ALT+F12 = Displays the VMkernel log on the console.
- [WayBack] How to access the VMware ESXi hidden console
- [WayBack] How to access DCUI/Console of ESXi using ALT+F Keys (2148363)
- Enabling/disabling SSH server and client in the firewall:
[root@ESXi-X9SRI-F:~] esxcli network firewall get Default Action: DROP Enabled: true Loaded: true [root@ESXi-X9SRI-F:~] esxcli network firewall ruleset list --ruleset-id sshClient Name Enabled --------- ------- sshClient false [root@ESXi-X9SRI-F:~] esxcli network firewall ruleset set --ruleset-id sshClient --enabled true [root@ESXi-X9SRI-F:~] esxcli network firewall ruleset list --ruleset-id sshClient Name Enabled --------- ------- sshClient true [root@ESXi-X9SRI-F:~] esxcli network firewall ruleset set --ruleset-id sshClient --enabled false [root@ESXi-X9SRI-F:~] esxcli network firewall ruleset list --ruleset-id sshClient Name Enabled --------- ------- sshClient false
–jeroen
Leave a comment