ssh,scp带密码操作(转载)

ssh,scp带密码操作

1、远程执行,带密码参数

  • sshpass 安装命令:
yum install sshpass 
  • 执行命令:
sshpass -p "mima" ssh root@localhost                                     
    -p:密码mima

2、非22端口

ssh -p 9062 192.168.0.1 "/root/xx.sh"              
    -参数小写p,端口9062

scp -P 9062 -r dist 192.168.0.1:/opt                              
    -参数大写P,端口9062

3、带密码参数非22端口

sshpass -p "mima" ssh -p 9062 192.168.0.1 "/root/xx.sh"
    -参数小写p,端口9062

sshpass -p "mima" scp -P 9062 -r dist 192.168.0.1:/opt
    -参数大写P,端口9062

转载文档

https://cloud.tencent.com/developer/article/1449403
posted @ 2020-09-01 13:47  evescn  阅读(3147)  评论(0编辑  收藏  举报