When an exception is thrown, paramiko. Ssh_exception. AuthenticationException: Authentication failed.
Please check:
1. Is port 22 enabled on the cloud server?
2. Is the password wrong when passing the parameter?
Error reporting example:
Operation method:
Take my Tencent Cloud as an example:
1. Click the security group rule to check whether the server opens port 22:
2. Check whether the code transmission parameter: account password is correct:
import paramiko
# 实例化SSHClient
client = paramiko.SSHClient()
# 自动添加策略,保存服务器的主机名和密钥信息,如果不添加,那么不再本地know_hosts文件中记录的主机将无法连接
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# 连接SSH服务端,以用户名和密码进行认证
client.connect(hostname='192.168.1.105', port=22, username='root', password='123456')
# 打开一个Channel并执行命令
stdin, stdout, stderr = client.exec_command('df -h ') # stdout 为正确输出,stderr为错误输出,同时是有1个变量有值
# 打印执行结果
print(stdout.read().decode('utf-8'))
# 关闭SSHClient
client.close()
3. After checking, run the Linux command with Python:
Read More:
- Installing sklearn (scikit learn) module related to Python machine learning in Windows
- Learning notes of Python 3: debugger speedups using Python not found
- PHP try will also throw an exception if it is executed successfully
- Error in Python connection to mongodb pymongo.errors.OperationFailure : Authentication failed.
- When python installs pocketsphinx module (package), an error is reported: command ‘swig.exe’ failed: No such file or directory
- Encountered a problem — Python — Python 3 uses Sqlalchemy to report an error‘
- [Error resolution] paramiko.ssh_exception.SSHException: Error reading SSH protocol banner setting
- Inexplicable exception 007: git error: authentication failed for
- Can’t find Python executable “D:\python3\python.exe”, you can set the PYTHON env variable.
- Pychar reported an error. Unable to set the python SDK in Python 3.8. This SDK appears to be invalid.
- python3 request module https certificate verify failed error
- Solve the problem of unable to locate package python3.6 when upgrading from python3.5 to python3.6 in ubantu16.04
- Python error: importerror: DLL load failed: unable to find the specified module solution
- Summary of Python deep learning packages
- The Python PIP installation module prompts the error failed to create process
- Error loading Python DLL ‘python36.dll’. LoadLibrary: The specified module could not be found.
- yarn install gyp verb `which` failed python2 Error: not found: python2
- Python import GDAL failed: DLL load failed. The specified module cannot be found.
- Python keyerror exception
- Solutions to the failure of importing Python 3.7 SSL module