Я пытаюсь подключиться к SFTP-серверу, размещенному кем-то другим, для которого включена аутентификация по паролю и publicKey.
Я пытался подключиться к нему с
sftp -v -i privateKeyPath user@serverip
Но тогда происходит сбой даже без запроса пароля со следующими ошибками:
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to serverip [serverip] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file privateKeyPath type -1
debug1: key_load_public: No such file or directory
debug1: identity file privateKey-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version JSCAPE
debug1: no match: JSCAPE
debug1: Authenticating to serverip:22 as 'user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32
debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<8192<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:VzWrzE4sfQyGqhxLRK48o3EcUkMajTFdzo/JcSZ9bJg
debug1: Host 'serverip' is known and matches the RSA host key.
debug1: Found key in /home/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password,publickey
debug1: Next authentication method: publickey
debug1: Trying private key: privateKeyPath
Authenticated with partial success.
debug1: Authentications that can continue: password,publickey
Затем я попытался принудительно установить аутентификацию по паролю, прежде чем publicKey
sftp -v -oPreferredAuthentications=password,publickey -i privateKeyPath user@serverip
и я могу успешно соединиться с сервером, но мне пришлось вводить один и тот же пароль трижды, потому что есть какой-то способ автоматизировать этот процесс, избегая ручного ввода пароля, и это тоже трижды.
OpenSSH_7.4p1, OpenSSL 1.0.1k-fips 8 Jan 2015
debug1: Reading configuration data /home/.ssh/config
debug1: /home/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 59: Applying options for *
debug1: Connecting to serverip [serverip] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity fileprivatekey type -1
debug1: key_load_public: No such file or directory
debug1: identity fileprivatekey-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version JSCAPE
debug1: no match: JSCAPE
debug1: Authenticating to serverip:22 as 'user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32
debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<8192<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:UyjhDdPiB4Fy0ut6nTZ5fZI6UpnXK6tke2dgizN1xys
debug1: checking without port identifier
Warning: Permanently added '[serverip]:22' (RSA) to the list of known hosts.
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password,publickey
debug1: Next authentication method: password
user@serverip's password:
Authenticated with partial success.
debug1: Authentications that can continue: password,publickey
Permission denied, please try again.
user@serverip's password:
Authenticated with partial success.
debug1: Authentications that can continue: password,publickey
Permission denied, please try again.
user@serverip's password:
Authenticated with partial success.
debug1: Authentications that can continue: password,publickey
debug1: Next authentication method: publickey
debug1: Trying private key:privatekey
debug1: Authentication succeeded (publickey).
Authenticated to serverip ([serverip]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending subsystem: sftp
Connected to serverip.