Accessory buildings shall not be erected in any required yard, except a rear yard; provided, further, that in no instance shall such a building be nearer than five feet to any rear lot line, nor in any case nearer than the required side yard for the principal building for the district in which it is located.