aws ec2のLinuxから自社オンプレサーバへのSSHがbash上では成功するがParamikoを使ったPythonからは失敗します。
どなたか、お助けくださいm(_ _)m
【バージョン】
SSHクライアント側OS:Amazon Linux AMI release 2018.03
4.14.33-51.37.amzn1.x86_64 #1 SMP Thu May 3 20:07:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
SSHサーバ側OS:Red Hat Enterprise Linux Server release 6.3 (Santiago)
Python:3.6.6
Paramiko:2.4.1
【コード】
python3
1import boto3 2import paramiko 3 4apl_ip = 'IPアドレス' 5user = 'ユーザ名' 6ssh_key_file = 'SSH鍵ファイル' 7port = 22 8command = 'touch /tmp/python_test' 9 10with paramiko.SSHClient() as ssh: 11 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 12 ssh.connect(hostname=apl_ip, port=port, username=user, key_filename=ssh_key_file) 13 stdin, stdout, stderr = ssh.exec_command(command)
【エラーメッセージ】
python3
1Exception: Indecipherable protocol version "}" 2Traceback (most recent call last): 3 File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/paramiko/transport.py", line 1893, in run 4 self._check_banner() 5 File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/paramiko/transport.py", line 2055, in _check_banner 6 raise SSHException('Indecipherable protocol version "' + buf + '"') 7paramiko.ssh_exception.SSHException: Indecipherable protocol version "}" 8 9Traceback (most recent call last): 10 File "<stdin>", line 3, in <module> 11 File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/paramiko/client.py", line 392, in connect 12 t.start_client(timeout=timeout) 13 File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/paramiko/transport.py", line 545, in start_client 14 raise e 15 File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/paramiko/transport.py", line 1893, in run 16 self._check_banner() 17 File "/root/.pyenv/versions/3.6.6/lib/python3.6/site-packages/paramiko/transport.py", line 2055, in _check_banner 18 raise SSHException('Indecipherable protocol version "' + buf + '"') 19paramiko.ssh_exception.SSHException: Indecipherable protocol version "}"
回答2件
あなたの回答
tips
プレビュー