def only_hostname(s):
    """
    Given an SSH target, returns only the hostname.

    e.g. only_hostname('user@mydomain:port') == 'mydomain'
    """
    return s.split('@')[-1].split(':')[0].strip()
