I think your problem is not constrained enough to have an interesting answer. Notice that your intertwining condition can be rephrased by saying that $g: B \to A$ is a homomorphism of $R$-algebras, where $A$ is given the structure of $R$-algebra given by $f$. In these terms, what you are looking for is the comma category $\mathcal{C} = (\mathbf{Alg}_R \downarrow A)$, whose objects are precisely the pairs $(B, g)$ as above, and whose morphisms $\operatorname{Hom}_{\mathcal{C}}((B, g), (B', g'))$ are the $R$-algebra homomorphisms $h: B \to B'$ such that $g = g' \circ h$. I am not sure it is possible to capture this beast with a cohomology group of any sort.
What you can do is restrict the class of objects that you are looking at. For example, you can classify square-zero extensions: fixing an $A$-module $I$, you can look at $R$-algebras $B$ such that you have a short exact sequence $0 \to I \to B \to A \to 0$; the name square-zero comes from the fact that $I$ is an ideal of $B$ with $I^2 = 0$. You can read about them in the first chapter of Sernesi's Deformations of Algebraic Schemes.