sshpass报错 Permission denied, please try again.和 connect to host localhost port 10022: Connection refused

最近在做自动化时,自动化脚本用sshpass给远程机器发送命令(sshpass -p "123456" ssh -p 10022 root@localhost -o StrictHostKeyChecking=no "poweroff")

报错:Permission denied, please try again. 和 ssh: connect to host localhost port 10022: Connection refused  

 

1.Permission denied, please try again.  

修改/etc/ssh/sshd_config里的 PermitRootLogin prohibit-password    改成     PermitRootLogin yes

然后重启ssh服务或重启机器,如果还是报这个错误,检查密码是否正确

 

2. ssh: connect to host localhost port 10022: Connection refused  

换了端口,将10022换成22

 

posted @ 2023-05-24 16:12  腹肌猿  阅读(741)  评论(0编辑  收藏  举报