设置身份文件,但没有环境变量仍然无法 ssh

设置身份文件,但没有环境变量仍然无法 ssh

我正在尝试在 crontab 上设置 scp 作业,并通过控制台测试该功能。crontab 不导入环境变量,因此我通过 进行测试env -i,同时还通过 导入身份密钥ssh -i

env -i sh -c "ssh -i /home/myname/.ssh/id_rsa box hostname"

但是,这不起作用,我只是得到了Permission denied (publickey)。我认为我的密钥设置正确。我已将我的公钥附加到远程框的 authorized_key 文件中。

在两台机器上,我都在 /etc/ssh/sshd_config 中设置了这些:

PubkeyAuthentication yes
RSAAuthentication yes

这是我在远程主机上的 auth.log 中收到的错误:

Sep 13 21:45:13 box sshd[59109]: userauth-request for user myuser service ssh-connection method publickey remote_ip <someip> remote_port 51635 attempt 1 failures 0 [preauth] session=box:57d87369.6185

编辑2:

跑步时...

SSH_AUTH_SOCK="" ssh -vv -i /home/myuser/.ssh/id_rsa myuser@myhost

我懂了...

debug2: key: /home/myuser/.ssh/id_rsa (0x7fc5ee0d15a0), explicit
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/myuser/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

我尝试手动将文件附加到authorized_keys,后来也尝试了ssh-copy-id。.ssh/目录是700

相关内容