Yes they are aphids. The ants 'farm' them by moving them about the
plants to new growth where they milk them for the sweet sticky excretions they provide. You can spray them with insecticidal soap and/or whiteoil, or a number of other sprays like garlic/chilli sprays.. These may also damage populations of ladybeetles and other predators which feed on the aphids.
Alternatively, you can line the trunk of the
plant with something which stops the ants from climbing up the
plant. A bit difficult on cucumbers methinks.(Those green pot scourers wrapped around the trunk are supposed to work for this). Then allow beneficial insects to take care of the aphids. You can assist them by squishing them with your fingers or blasting them off with a jet from the hose.
Ensure your
plants receive potash in their fertilizer to help toughen new growth quickly. It also helps with fruit forming. High nitrogen ferts can cause lots of lush leafy growth which is a perfect situation for these pests.