Two methods I can think of. Expanding the right hand side terms or completing the square on the left. After that you compare
Expanding the term:
x^2 - 6x + 1 = (x-a)^2 - b = x^2 - 2ax + a^2 - b
x^2 - 6x + 1 = x^2 - 2a(x) + (a^2 - b)
Look at the coefficients on the x terms. -6 and -2a. They must be equal, so a=3. Similarly look at the constant. 1 and (a^2 - b) which is nothing but (9-b). They must be equal again, so b=8
Completing the square:
x^2 - 6x + 1 = [x^2 - 2(3)x + 3^(2)] - 3^2 + 1 = (x-3)^2 - 8
(x-3)^2 - 8 = (x-a)^2 - b
Simple comparison will get you the answers here