Linux Shell脚本实现自动交互
2012-11-23 14:00
302 查看
方法一:(以OpenSSH编译完成之后的 拷贝和生成key 为例)
#!/bin/bash DIR_PATH=$HOME/sshdfile cp sshd $DIR_PATH/sbin cp scp sftp ssh ssh-add ssh-agent ssh-keygen ssh-keyscan $DIR_PATH/bin cp sftp-server ssh-keysign $DIR_PATH/libexec cp sshd_config ssh_config $DIR_PATH/etc chmod 755 $DIR_PATH/var/empty ssh-keygen -t rsa1 -f ssh_host_key -N "" << EOF y EOF ssh-keygen -t rsa -f ssh_host_rsa_key -N "" << EOF y EOF ssh-keygen -t dsa -f ssh_host_dsa_key -N "" << EOF y EOF cp ssh_host_* $DIR_PATH/etc
方法二:(以FTP用户自动登录为例)
#!/usr/bin/expect set file [lindex $argv 0]; set timeout -1; spawn ftp 192.168.1.*** expect "Name" send "username***\r" expect "Password" send "passwd***\r" expect "ftp>" send "hash\r" expect "*ftp>*" send "put $file\n" expect "*ftp>*" send "bye\r" expect "*Goodbye*" expect eof exit【测试】:./autoftp.sh filename
【效果】:自动登陆FTP用户”username***“, 将”filename“ 文件上传至服务器。
相关文章推荐
- shell脚本实现无密码交互的SSH自动登陆
- Linux shell脚本实现yum源配置(用户交互版和预定义配置版)
- shell脚本实现无密码交互的SSH自动登陆
- Linux安装脚本需要交互之如何实现自动安装
- 使用expect实现自动交互,自动登录脚本
- 通过脚本实现linux上安装的自动交互
- Linux Shell Script Programming —— 实现自动交互
- shell脚本实现无密码交互的SSH自动登陆
- shell脚本实现无密码交互的SSH自动登陆
- linux shell使用expect实现sftp的自动交互
- Shell脚本——与Linux Shell自动交互
- 实现Linux Shell自动交互的三种方法----本人备注
- 利用Linux Shell脚本实现MySQL自动监控和报警
- Linux-----Shell脚本交互实现自动输入密码
- shell脚本实现无密码交互的SSH自动登陆
- Linux下实现脚本的自动交互
- 无密钥登录的自动脚本实现(ssh-copy-id、expect免交互输入脚本)
- 实现Linux Shell自动交互的三种方法
- 用expect实现shell脚本的自动交互
- 无密钥登录的自动脚本实现(ssh-copy-id、expect免交互输入脚本)