We report an experimental proof of principle for ghost imaging in the hard-x-ray energy range. We use a synchrotron x-ray beam that is split using a thin crystal in Laue diffraction geometry. With an ultrafast imaging camera, we are able to image x rays generated by isolated electron bunches. At this time scale, the shot noise of the synchrotron emission process is measurable as speckles, leading to speckle correlation between the two beams. The integrated transmitted intensity from a sample located in the first beam is correlated with the spatially resolved intensity measured in the second, empty, beam to retrieve the shadow of the sample. The demonstration of ghost imaging with hard x rays may open the way to protocols to reduce radiation damage in medical imaging and in nondestructive structural characterization using free electron lasers.