#!/bin/bash
read -ep “请输入ip:” ip
read -ep “请输入密码:” passwd
read -ep “请输入文件绝对路径:” file
/usr/bin/expect <<EOF
spawn scp $file KaTeX parse error: Undefined control sequence: \n at position 34: …yes" {send "yes\̲n̲;exp_untinue"}
…passwd\n"}
expect “100%” {send "echo “$ip:成功”}
expect eof
EOF
本文介绍了一个使用Bash脚本实现的SSH远程文件传输过程。通过交互式读取用户输入的IP地址、密码及文件绝对路径,利用expect工具自动化处理SSH密钥交换过程,最终完成文件的远程复制。此脚本适用于需要频繁进行远程文件传输的场景。
5547

被折叠的 条评论
为什么被折叠?



