It shall be lawful for any person of whom a bond, undertaking or other obligation is required, to agree with his surety or sureties for the deposit of any or all money and assets for which he and his surety or sureties are or may be held responsible, with a bank, savings bank, safe-deposit or trust company, authorized by law to do business as such, or with other depository approved by the court or a judge thereof, if such deposit is otherwise proper, for the safekeeping thereof, in such manner as to prevent the withdrawal of such money or assets or any part thereof, without the written consent of such sureties, or upon an order of court, or a judge thereof, made on such notice to such surety or sureties as such court or judge may direct. Such agreement shall not in any manner release from or change the liability of the principal or sureties as established by the terms of the bond.