BashスクリプトでSSHキーを使用する

BashスクリプトでSSHキーを使用する

openssh と秘密鍵/公開鍵を使用して Windows 2003 サーバーから Unix サーバーに接続しようとしていますが、秘密鍵のパスワードと Windows のパスワードの入力を求めます。

Linuxの認証された鍵に公開鍵を追加しました(パテを使用して接続し、秘密鍵が正しく機能している場合)。ただし、パスワードとパスワードを要求せずにbashスクリプトを使用して接続する必要があります。

これはコマンドです:

ssh -v -i privatefile -p 2022 user@server

ログは次のとおりです。

OpenSSH_3.7.1p1, SSH protocols 1.5/2.0, OpenSSL 0.9.7b 10 Apr 2003
debug1: Connecting to SERVER port 2022.
debug1: Connection established.
debug1: identity file privatefile type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.7.1p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-sha1 none
debug1: kex: client->server aes128-cbc hmac-sha1 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'SERVER' is known and matches the RSA host key.
debug1: Found key in /cygdrive/c/Users/PAMA1/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
D:\Entrada\z_Bkp>NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received

Anyone gaining unauthorized access will be subject to PROSECUTION.

debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mi
c,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: bilaetlopenssh
Enter passphrase for key 'bilaetlopenssh':
debug1: Next authentication method: keyboard-interactive
Enter your Windows password :

ベストアンサー1

を使用している場合は、putty次のものを使用できます。puttygenキー秘密キーは動的に保存され、パスワードキーは一度(つまり再起動するまで)入力されます。

推奨されるアクションは、リモートホスト、リモートユーザー、および使用されたキーを使用してセッションを保存し、そのセッションを使用してコマンドを実行することです。会議

\path\name\to\putty.exe -load "mysession"

したがって、パテのコピーを使用するには、次の手順を実行しますpscp

\path\name\to\pscp.exe -load "mysession" local-file.txt remote:/path/file.txt
\path\name\to\pscp.exe -load "mysession" remote:/path/file.txt local-file.txt

Unixの世界ではputtygenこれをssh-addテストするためのWSLはありません。

おすすめ記事