我正在尝试使用 ssh 自动将 Web 应用程序交付到服务器。
在服务器上,我创建了一个单独的 Linux 用户并代表它运行 ssh-keygen 命令。
然后我将私钥复制到我的计算机并运行命令
ssh -i id_rsa -oBatchMode=yes -v github-deployer@<ip сервера>
我得到一个错误Permission denied (publickey,password)
同时,服务器配置没有问题,我可以代表另一个用户轻松连接,尽管我以不同的方式生成了密钥(我在我的计算机上生成并上传了服务器的公钥)。
在文件/var/log/auth.log中,当我尝试连接时,我只看到一行:
Jun 27 12:28:07 seterator sshd[20567]: Connection reset by 46.242.39.189 port 64510 [preauth]
使用 -v 开关运行 ssh 客户端时,输出如下:
debug1: Reading configuration data C:\\Users\\m.prokazin/.ssh/config
debug1: Connecting to <ip сервера> [<ip сервера>] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\m.prokazin\\Documents\\tmp\\key type 0 # <- это реальный путь к файлу приватного ключа
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\m.prokazin\\Documents\\tmp\\key-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4p1 Debian-10+deb9u7
debug1: match: OpenSSH_7.4p1 Debian-10+deb9u7 pat OpenSSH* compat 0x04000000
debug1: Authenticating to <ip сервера>:22 as 'github-deployer'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:g30wkiuNuaw6RZVbq0F0EsRyA1Gw8vbHfNruCF7iAS0
debug1: Host '<ip сервера>' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\m.prokazin/.ssh/known_hosts:41
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:lvQ7LKb8X8XS/Gx5TmsldZ+aqwyAl6teujJB+dTBaYI C:\\Users\\m.prokazin\\Documents\\tmp\\key
debug1: Authentications that can continue: publickey,password
debug1: No more authentication methods to try.
github-deployer@<ip сервера>: Permission denied (publickey,password).
这整个情况也在我按计划连接以上传更新的机器上重现。
可能是什么问题呢?
authorized_keys在服务器上输入了公钥~/.ssh