windows_host文件路径:C:\Windows\System32\drivers\etc

ssh-copy-id -i ~/.ssh/id-rsa.pub root@xxxxxxx 免密验证操作

/etc/ssh/ssh_config

执行远程脚本
#!/bin/bash
ssh root@xxxxxxxx > /dev/null 2>&1<eeooff
cd /root
touch testljc
exit
eeooff
echo done


yum install openssh-client
yum install openssh-server


#PubkeyAuthentication yes

##########################################

yum -y install expect
expect b.sh
执行远程登录 密码或者无密码(免密认证)
#!/usr/bin/expect
spawn ssh root@10.0.18.65
expect "*password:" #截取关键词(有密码)
send "jenkins\r" #发送密码
expect "*#" #截取关键词
send "touch abc.txt\n"#输入命令
send "exit\n" #退出
interact #保证正确性

spawn ssh root@10.0.18.22
send "exit\n" #输入命令及退出
interact #保证正确性


ssh -p 端口 IP 'sh /root/text.sh' 首先是已经免密登录 接着可以执行远程ip的目录下的脚本 且会返回数据 可设置加以互动

相关文章:

  • 2021-07-16
  • 2021-06-01
  • 2021-12-29
  • 2022-12-23
  • 2021-08-28
  • 2021-09-01
  • 2021-08-12
  • 2021-12-24
猜你喜欢
  • 2021-05-23
  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2021-11-30
  • 2021-07-03
相关资源
相似解决方案