我转换了由jenkins CI服务器安装创建的非登录用户jenkins
,以允许通过执行以下操作登录:
然后我通过
创建了一个公共私钥对现在,在机器上,我可以su - jenkins
成为jenkins用户。但是,在远程计算机上,我不能使用公共密钥ssh到这台机器(作为具有相应密钥的jenkins用户)。
我通过useradd在机器上创建了一个新用户,将jenkins ssh密钥复制到此帐户,并且能够使用密钥以此用户身份登录。
我完全不知道jenkins用户可能阻止ssh公钥访问的特殊情况。在我脑海中唯一突出的是jenkins用户 使用用户ID 498创建。阻止'系统'用户阻止ssh吗?
启用-v
的ssh命令结束登录失败,因为用户jenkins看起来像这样:
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Next authentication method: publickey
debug1: Trying private key: id_rsa
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
以用户foo成功登录(使用相同的密钥):
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Next authentication method: publickey
debug1: Trying private key: id_rsa
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
Authenticated to jenkins.internal.nara.me ([54.83.203.146]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
答案 0 :(得分:1)
你可能会遗漏这些内容:
调试此问题,使用
重新加载sshdLogLevel VERBOSE
中的
并查看/var/log/auth.log(或等效的centos)以获取有关为何不接受此密钥的信息。在详细模式下,sshd总是说出原因;)