A would-be robber who tried to steal £200 from a pensioner at a cash machine has been jailed for three years.