How do i rotate something on a new rotation axis?

It’s hard to be specific but il try to explain my problem via picture

So i want to rotate the cylinder 45 degrees on the axis that its facing the ball object.
(I don’t want to rotate the cylinder to face the object and then rotate it 45 degrees)
Axis is presented in magenta.

You get the axis using the cross product (Vector3.Cross()) between the Up Vector and the vector to the ball. So the code would be something like this (untested):

var v3 = ball.transform.position - transform.position;
var v3Axis = Vector3.Cross(v3, transform.up);
transform.RotateAround(transform.position, v3Axis, 45.0);

Note this assumes the script is attached to the cylinder. Also you may have to reverse the parameters in the Vector3.Cross() to get the rotation to go the correct direction.