Cells swimming in confined environments are attracted by surfaces. We measure the steady-state distribution of smooth-swimming bacteria (Escherichia coli) between two glass plates. In agreement with earlier studies, we find a strong increase of the cell concentration at the boundaries. We demonstrate theoretically that hydrodynamic interactions of the swimming cells with solid surfaces lead to their reorientation in the direction parallel to the surfaces, as well as their attraction by the closest wall. A model is derived for the steady-state distribution of swimming cells, which compares favorably with our measurements. We exploit our data to estimate the flagellar propulsive force in swimming E. coli.