vCF External Backups using a Windows SFTP Server and the D:\

I was working with a customer who wanted to configure a Windows SFTP server as the backup target for their VCF SDDC backups, and it was a bit of a pain to get working right, although in the end it wasn't too complicated.  So, I'm writing my notes here!

In this environment, the server is not given internet access, so installing the OpenSSH feature took a bit of extra work in Windows.  The key there was to download the FOD ISO from Microsoft and mount that to our VM (not the normal Windows install ISO).  Once that ISO was mounted (as the E:\ drive), I used the following DISM command to install the OpenSSH Server optional feature:

dism /add-capability /online /capabilityname:OpenSSH.Server~~~~0.0.1.0 /source:E:\LanguagesAndOptionalFeatures

That got OpenSSH installed, so I made sure that the service was set to Automatic in Windows and figured that we were good to go!  Not quite...

The server needed some configuration.  The config file is "C:\ProgramData\SSH\sshd_config" and can be opened with Notepad or any other text editor; just make sure that you have an elevated application, otherwise you won't be able to save your changes!

We need to make three configuration changes to make this work smoothly.  First, we'll want to set the default directory to the folder that we're using.  In this case, if we want our backups to go to the D:\SFTP\Backups\ directory, we'll want to change the line that reads:

"Subsystem    sftp    sftp-server.exe"

into:

"Subsystem    sftp    sftp-server.exe -d D:\SFTP"

Next, we'll need to change the root directory to the D:\ drive for this server.  The VCF interface needs you to specify a backup folder, but the way that Windows advertises that folder it's going to effectively need an absolute path, but packaged in SFTP dressings.  If you use WinSCP and connect to the server, you'll see that the path is "/D:/SFTP/Backups" but that presents a problem.  The vCF interface will not allow you to input a ":" character in that field... but fortunately, there's a work-around!  OpenSSH on Windows will treat the standard linux root "/" as the C:\ by default.  In this case, we don't want to use the C:\, but we can edit the config file to give it a new root!

Add this line to the config file (or uncomment the example and change it):

"ChrootDirectory D:\"

That will instruct OpenSSH to treat "/" as a reference to D:\.  That means that you can configure that backup directory as /SFTP/Backups in the vCF interface and it'll all get sorted out on the back-end.

Finally, we'll need to make sure that our user account is allowed to access the server.  I could not figure out a syntax that VCF would accept that allowed me to specify a domain account, so we eventually ended up creating a local account on the SFTP server (for this example, we'll call that account backupUser).  We just need to add a line to the config file that tells the system that that user is allowed to sign in to the server:

"allowedUsers backupUser"

Once those three changes have been put in place (and you've ensured that your folder NTFS permissions are correct for the specified account), you'll just need to restart the OpenSSH SSH Server service so that it will read in the new configuration, and you should be good to go!

Comments

Popular posts from this blog

Clone a Standard vSwitch from one ESXi Host to Another

PowerShell Sorting by Multiple Columns

Deleting Orphaned (AKA Zombie) VMDK Files