I am in a bit of a sticky situation. I started my current job a few months ago, and I have a web application running on an apache web server (a simple PHP-based one). I need to update this code to fix some problems in the application, and I'd like to get the code into a proper source code environment (IE. Version Control).

Skipping explanation of irrelevant details, I need to retrieve a directory (folder) from an Ubuntu Server 14.04 (CLI) Virtual Machine without adding or removing any software or other files to the machine. Currently the machine has no FTP or SCP server on it, so I cannot use those. And it's missing the /sbin/mount.nfs helper program to allow the mounting of an NFS share (we have a series of shared folders here that I could potentially use to retrieve the files if I could mount an NFS share).

Currently I only have one idea, which is to insert a USB Flash Drive into the ESXi host that is running the machine, and copying the files to that. However, the machine doesn't have a USB controller, and because it is a production machine I cannot shut it down during the workday to install one, so I'll only be able to do this after business hours. Because of this, (TLDR:) I was wondering if anyone else had any other ideas on how to retrieve a directory from a Ubuntu Server 14.04 VM without FTP, SCP, Mounting an NFS Share, or installing any new files or software.

Edit: Didn't expect all the great responses. Removing my accepted answer for now. I'll assign it elsewhere when I have a good chance to go through these responses and experiment.

  • 4
    So, no ssh even?
    – EEAA
    Jul 28, 2016 at 13:12
  • 7
    Cripes dude, honestly. This is a completely unreasonable situation, and you've put unreasonable constraints on it. Root into the console of the server and get SSH running.
    – EEAA
    Jul 28, 2016 at 13:15
  • 5
    But you are able to somehow run commands (via shell access) on that server, right? Could you use existing clients on that server (e.g. ftp, scp, etc) to upload the tar'd up directory from your Ubuntu server to some other machine on which you can install server software for receiving that folder?
    – Castaglia
    Jul 28, 2016 at 16:51
  • 8
    It would have been useful to know what you can do. Can you execute commands on the machine? As root? How do you do that if not via ssh? Create files? Set executable bit? Execute programs and scripts? Is tar available? bash? netcat aka. nc? socat? curl? wget? telnet? busybox? zmodem support e.g. via lrzsz? Could you transfer and use a static copy of any of these programs, typing in hex digits if you had to?
    – MvG
    Jul 28, 2016 at 23:32
  • 8
    ...so low on drive space that installing anything will cause the databases to stop... Is this prodiuction server expected to continue running in the future? Jul 29, 2016 at 9:24

8 Answers 8


As well as saying all the things it doesn't have, what about saying the things it does have? How big is the folder and how much free disk space is there?

Assuming you have no access to the CLI at all, even from the console:

  1. If it's ESXi 5.0 or above, and the server has VMware Tools installed, use PowerCLI and the Copy-VMGuestFile cmdlet to copy files from it.
  2. It's a VM, restore a backup of it somewhere isolated, boot it, make all the changes you like to get at the files.
  3. It's a VM, restore a backup of the disk and download and mount the VMDK file.

Even though you don't have SSH access, assuming you have some kind of access to type commands and manage the server via the VM console:

  1. It's a web server, download the files through a browser
    1. Maybe gzip them into /tmp (memory) and symbolic link into the webserver folder to avoid changing Apache config
  2. Does it have FTP client installed? FTP from the server to somewhere else and upload the files.

    1. Does it have SSH client installed? SCP them from the server to a remote SSH server
    2. Email them to yourself
    3. WGET/Curl POST them to a remote web server upload
    4. TFTP them out
  3. Does it have netcat (nc) installed? You can pipe tar | nc and stream the data to a socket, and use nc | tar on another computer on the network to receive. example

  4. If it's a typical Linux install, it might have Python on it, Python comes with SimpleHTTPServer module which defaults to serving the current directory as a website, run that on a different port to the main webserver and download the files from there.
  5. Script stuffing them into your database as a binary blob into an in-memory table, and then selecting them out from a client maybe relevant
  6. Does the server syslog to a remote destination? Base64 encode the files and stream them into the syslog... ymmv on reading it back.
  • 1
    Upvoting for #2 - one of the great benefits of VMs is the ability to make copies to mess with in a test environment. OP is lucky enough to have this server in a VM - use it, install any software on the copy, then delete the copy.
    – Jake
    Jul 28, 2016 at 18:03
  • 1
    What @Jake said, but I'm upvoting for all the other points raised as well. Good job! The accepted answer stating "[...] You literally have zero options here [...]" is just nonsense.
    – gxx
    Jul 28, 2016 at 23:13
  • +1 for comprehensive brainstorm of plausible out-of-the-box solutions.
    – Skyhawk
    Jul 28, 2016 at 23:45
  • sshfs is a really nice way to work with remote files over ssh. Jul 29, 2016 at 15:12
  • Another option would be to make a copy of the disk and mount the copy on another VM, where you can access with a different system and read the contents in the disk (assuming it isn't encrypted). Jul 30, 2016 at 15:56

If the server has Python installed -- which it almost certainly does; Python is used by enough system services that it's pretty much guaranteed to be present -- you can start up a HTTP server to serve files from the current directory using the command:

python -m SimpleHTTPServer 9999

to start up a web server on port 9999.

Keep in mind that there are no access controls on this server, so you may not want to do this if the server is accessible to the public.

Another option will be to pipe a tar archive over the network. Assuming that you have another computer (host name "client") at IP address that's reachable from the Ubuntu server, you can do this by running the following command on the client:

nc -lp 9999 > files.tar.gz

and running on the host:

tar cz /path/to/directory > /dev/tcp/

While this does create an archive, the archive is never written to disk -- it's streamed directly over the network -- so there is no risk of running out of disk space.


The virtual machine disk is hopefully stored in a way that is backed up regularly - so you can restore the backup to a new location and then use the VM disk as a second disk in a new VM.

If there are no official backups, then there should be, and this needs sorting - but if the disk is stored on a LVM partition, you may be able to create a snapshot partition, and then copy the disk from there as though it was a back up


Well, there is already an accepted answer, and in addition, there is a real good answer making use of the fact it is a web server.

But just to point out a line of attack that I don't think is addressed much is if you have command line access, you are probably using a terminal program, and most of those have some sort of way to log stuff that scrolls off of the screen.

So maybe this answer could help in the future for someone who doesn't have a web server running. Basically what might be called a field expedient file transfer using common Linux tools

One could send the folder as ASCII. Tar the folder, convert that from binary to ASCII using a number of possibilities. Then on the machine running the terman program, recover the ASCII blob from scrollback, and extract the binary from it.

tar czf - folderpath | uuencode temp.tar.gz


tar cvf - folderpath | base64

will dump a huge block of text to your terminal. If you can capture that as scrollback, clean it up a bit in a text editor, then decode it back to binary, you'll have a tar.gz of the folder. Sure, you might have to do something like set your scroll back in putty to a huge amount of lines.

I think you could even use xxd to do the encoding and decoding if you wanted to.

If you couldn't fit it in scrollback in one time, you could even break it up using head and tail and send the ASCII over a chunk at a time.

Details depend on what utilities you have access to and how much effort you want to take squeezing that data through a console data stream

(OP should use the web server)

  • Of course depending upon your patience once you have base64 there is email and printing.
    – mckenzm
    Jul 30, 2016 at 11:05

While that is the ESXi VM you have to get another vmdisk attached to it. Then move everything noncritical to that disk and install tool of yor choice - ssh/scp/rsync/everything else.


If you are able to run shell commands on the server, then you can run tar with the right arguments to create a .tar (or .tar.gz) archive containing the files, and then you can run curl or wget to upload the archive to https://transfer.sh/ . From another computer you can retrieve the archive.

If you are unable to run shell commands on the server, then you should ask the sysadmin or DBA of the server how they run commands. (You mentioned that the server runs an important database, so there must be a way to run maintenance tasks.)

If you are able to upload .php files and make them run (i.e. serve web pages), then you can find an admin .php script which exposes a directory tree, upload it, and run it.


From another host, do:

 dd if=/dev/zero of=some-file.img bs=1k count=1000
 mkfs.fat some-file.img

Take file some-file.img on your desktop. The VMware client should be able to mount it as a floppy drive.

  • Adjust count=1000 to fit your need.

Create a new Vmdk on the data store. Attach it to the VM in runtime, discover it on the VM, partition it, create file system on it, mount it on a mount point and then copy over the data to it. Once done, unmount it, disconnect the Vmdk and then connect to a VM on which you have the ssh/sftp/nfs access. Then discover, mount and copy over to wherever needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.