Slice the lemons or limes and remove the pips. Place in a bowl with the onions and salt. Tie all the spices together in a square of muslin and add to the bowl with the vinegar. Leave for 8 hours or overnight.
Pour into a large heavy-based pan, and add the chillis and the ginger. Bring to the boil and simmer gently for 1½ hours. Remove from the heat and add the sugar. Stir until it has dissolved, then return to the heat. Boil fast for 20 minutes, stirring frequently to prevent catching. Remove the spice bag. Ladle the chutney into clean jars, cover and seal while hot. Keep for at least one month in a cool, dark place before opening.