def METHOD_NAME(session_target_sat, git_port):
    """Copy ssh public key to git service"""
    git = settings.git
    key_path = '/usr/share/foreman/.ssh'
    session_target_sat.execute(
        f'sudo -u foreman ssh-keygen -q -t rsa -f {key_path}/id_rsa -N "" <<<y'
    )
    key = session_target_sat.execute(f'cat {key_path}/id_rsa.pub').stdout.strip()
    title = gen_string('alpha')
    auth = (git.username, git.password)
    url = f'http://{git.hostname}:{git.http_port}'
    res = requests.post(
        f'{url}/api/v1/user/keys',
        auth=auth,
        json={'key': key, 'title': title},
    )
    res.raise_for_status()
    id = res.json()['id']
    # add ssh key to known host
    session_target_sat.execute(
        f'ssh-keyscan -t rsa -p {git.ssh_port} {git.hostname} > {key_path}/known_hosts'
    )
    yield
    res = requests.delete(
        f'{url}/api/v1/user/keys/{id}',
        auth=auth,
    )
    res.raise_for_status()