The process by which a viral protein binds to a pilus on the host cell surface. Pili are retractile filaments that protrude from gram-negative bacteria. Filamentous viruses can attach to the pilus tip, whereas icosahedral viruses can attach to the pilus side.