How to upload or download files to or from vCenter and ESXi hosts
search cancel

How to upload or download files to or from vCenter and ESXi hosts

book

Article ID: 403632

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

This is an instruction guide on how to upload files to vCenter and ESXi hosts using different methods according to what may be available on the environment.

Use the 2 first methods as preferable ones, the other methods are alternatives in case there are difficulties with these preferable methods.

 

Environment

vCenter Server appliance all versions

ESXi hosts all versions

Cause

Depending on each environment or situations faced by users, the usage of WinSCP or the Datastore upload will not be possible, hence this article will instruct you with different possibilities.

Resolution

Using WinSCP to upload files to vCenter or ESXi hosts [preferable for vCenter]:

  1. Download WinSCP installation or portable from this link.
  2. Run WinSCP and define the new session with these instructions:
    1. File protocol: SFTP
    2. Host name: The vCenter or ESXi FQDN or IP address.
    3. Port number: 22
    4. User name: root
    5. Password: <the root account password>
      * For vCenter only:
      1. Click Advanced
      2. Select SFTP
      3. In SFTP server, replace the default with this: shell /usr/libexec/sftp-server 
        This option is better than changing the bash of vCenter as it will not bring risks on changing the vCenter Photon OS settings.
        With this option, WinSCP will not return the error:
        "Received too large (1433299822 B) SFTP packet. Max supported packet size is 1024000 B.
        The error is typically caused by message printed from startup script (like .profile). The message may start with "Unkn".
        Cannot initialize SFTP protocol. Is the host running an SFTP server?"
    6. Click Login.
    7. Optionally, you can save the settings for further connections.
  3. You can choose Yes to accept to save the thumbprint of the server or no to continue without saving (then has to perform that operation every time you connect to the same server).
  4. Choose the correct destination location to upload the file or the location the file to be downloaded, for instance:
    1. Some tools such as scripts provided by Broadcom support are better placed on /root/ location in vCenter or in a datastore of the ESXi host.
    2. Some articles indicate a replacement of specific files, then the proper location shall be selected.
    3. Some files can be placed on /tmp/ just be aware they will be removed on a reboot of the vCenter or ESXi host.
    4. Support bundles generated with the command vc-support will be saved on /storage/log/
  5. Upload the file by dragging from the left panel or any other Windows Explorer window directly to the destination folder.
    You can also right click on the file in the left panel and choose "Upload" or selecting the file and pressing F5
  6. Click Ok to confirm the upload.
    If the file already exists, evaluate if the replace of it is safe, then press "Yes", otherwise press "No" and review the file replacement.

 

 

Uploading files to ESXi datastore using the vSphere Web Client [preferable for ESXi hosts]:

  1. Login to vCenter on vSphere Web client.
  2. Find the destination datastore in the "Datastores" tab of a specific host and click on it.
    Note that the host selected in vCenter not necessarily is the host that will be used to browse and upload the files, vCenter selects automatically the first available host to be used by the Web Client operations.
    You can also use the navigator icon to browse the datastores and select the destination.
  3. Select the "Files" tab.
  4. Find and click on the the destination folder where the file must be placed.
    Expand possible subfolders if necessary.
  5. Click on "Upload Files" or "Upload Folder" according to your requirements.
    In case you receive an error: "The operation failed. Details...", follow the steps of KB 343447, this can resolved on clicking in the link of the ESXi host that appears on the error to open a new tab in the browser, then after accepting the certificates of that host you can go back to vSphere Web Client and repeat the upload steps (no need to login to the host).

 

 

Uploading files to ESXi datastore using the host Web Client:

  1. Login using root account directly to the ESXi Web Client using https://ESXi_FQDN_OR_IP/ui
  2. Select "Storage" on the left panel.
  3. Click on the destination datastore in the main panel.
  4. Click on "Datastore Browser"
  5. Find the destination folder and click on it (or create a new folder).
    Note: vSAN datastore will show the UUID of the folders objects instead of the name of the folder, then it is necessary to find the destination folder based on that ID.
  6. Click on "Upload".
    Note: if necessary, use the bottom of the division columns to drag and increase the size of the panels for a better view of the contents.

 

 

Uploading files to vCenter if WinSCP is not available:

It is required SSH is responsive for this method, then you can use SCP command on Linux or Windows PowerShell (newer versions):

On executing the command on the first time to a server, it is reuqired to accept the thumbprint certificate of that destination server: just type "yes" and press ENTER.

 

How to copy a file from one location to another using scp command (push from source to the destination):

  • scp /SOURCE_FOLDER/sourcefile.file root@HOSTNAME_OR_IP:/DESTINATION_FOLDER

 

This can be useful to push files from a datastore in an ESXi host to a location inside vCenter, using the steps above to upload files to a host datastore.

  • scp /vmfs/volumes/DATASTORE/filename.file root@VCENTER_FQDN_OR_IP:/DESTINATION-FOLDER/

 

You can use this same method to upload or download files on ESXi host datastore if WinSCP or Web client are accessible.

To Download:

  • scp root@HOSTNAME_OR_IP:/vmfs/volumes/DATASTORE/filename.xxx /DESTINATION-FOLDER/

To Upload:

  • scp /SOURCE_FOLDER/filename.file root@VCENTER_FQDN_OR_IP:/vmfs/volumes/DATASTORE/SUBFOLDER/

 

 

Using a NFS shared location:

For vCenter, you can mount a temporary NFS server.

NFS shares are easily created, it is possible to enable the feature on Windows or Linux with few steps, check with your operating system vendor for steps to enable NFS server with shared folder.

To mount a NFS share on vCenter:

  1. Create a directory to be used for the mount
    • i.e.: mkdir /root/NFS
  2. Run this command to mount the share:
    • mount -f nfs NFS_SERVER_FQDN_OR_IP:/NFS_SHARE_NAME /root/NFS
  3. Copy the files accordingly using the "cp" command.
    • i.e.: cp /root/NFS/filename.file /root/
  4. Unmount the share with this command:
    • umount /root/NFS

 

To mount NFS share on ESXi hosts:

  1. Use the steps of the article Mount an NFS Datastore in the VMware Host Client or use the commands as per the KB 344470 
  2. If that location is not required for the functionalities of the ESXi host, unmount and remove the datastore after the temporary usage, KB 344470 has the instructions .

 

 

Using CD-ROM method:

You can create an ISO with the files required for the upload then attach that ISO to vCenter and ESXi hosts.

Note that to create the ISO you have to use any third party tool that has that ability.

Follow these steps to make vCenter be able to access the required files on vCenter:

  1. Attach the ISO to the vCenter VM.
  2. Mount the ISO into the vCenter OS using this command:
    • mount /dev/sr0 /mnt/cdrom
  3. Copy the required files from the CDROM to the destination location, i.e.:
    • cp /mnt/cdrom/filename.file /root/
  4. Unmount the CDROM with this command:
    1. umount /mnt/cdrom


Use the steps from KB 390910 to mount a CD-ROM to an ESXi host.

Summarized steps:

  1. Load the CDROM module:
    • vmkload_mod iso9660
  2. Mount the CDROM:
    • vsish -e set /vmkModules/iso9660/mount $(esxcfg-mpath -b | grep "CD-ROM" | awk '{print $1}')
  3. Access the files on /vmfs/volumes/mpx.vmhba64:C0:T0:L0 (or other location depending on the CDROM device in the hardware)
    This location cannot be accessed via GUI, therefore the command cp can be used.
    To enumerate the locations
  4. Unmount the CDROM after files are copied
    • vsish -e set /vmkModules/iso9660/umount $(esxcfg-mpath -b | grep "CD-ROM" | awk '{print $1}')
  5. Unload the CDROM module:
    • vmkload_mod -u iso9660
  6. Detach the ISO from the host.

 

 

With the recommendations above, you can use combinations on getting the files uploaded, for instance:

  • Use WinSCP to upload a file to vCenter then push that file to an ESXi using SCP command line.
  • Upload a file to an ESXi datastore using the host Web Client then use SCP command to download the file into the vCenter.
  • Mount a CD-ROM with the files on vCenter then use SCP command to push the files to the ESXi host datastore.
  • Mount an existing NFS datastore share to a Windows jump machine and copy the file to that location, then use SCP to copy that file from the host to the vCenter.

 

 

 

Additional Information

Please note that the use of WinSCP is at your own discretion. Since it is a third party tool, support for this tool is not provided by Broadcom support, and any issues or configurations related to it are the responsibility of the user.