Here is my setup:
keys need to generated from jenkins user.
sudo su jenkins ssh-keygen
once the key is generated, it should be added as ssh key in bitbucket or github.