私はPythonでこのような関数を持っています:
def test_ssh(host, username, password):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username=username, password=password)
問題は:
test_ssh('127.0.0.1', 'root', 'hello')
動作します
しかし、test_ssh('localhost', 'root', 'hello')
動作しません
私が得るエラーは次のとおりです:
ssh: Could not resolve hostname localhost: Name or service not known
これは何が原因ですか?ありがとう