Method 1: (take the copy and generate key after OpenSSH compilation as an example)
#! /Bin/bashdir_path = $ home/sshdfilecp sshd $ dir_path/sbincp scp sftp ssh-add ssh-Agent ssh-keygen ssh-keyscan $ dir_path/bincp sftp-server ssh-keysign $ dir_path/libexeccp sshd_config ssh_config $ dir_path/etcchmod 755 $ dir_path/var/emptyssh-keygen-T rsa1-F secure-n "<eofyeofssh-keygen-t rsa-F secure- N "" <eofyeofssh-keygen-t dsa-F ssh_host_dsa_key-n "" <eofyeofcp ssh_host _ * $ dir_path/etc
Method 2: (take FTP user automatic logon as an example)
#! /Usr/bin/expectset file [lindex $ argv 0]; set timeout-1; spawn FTP 192.168.1. * ** trusted CT "name" send "username *** \ r" trusted CT "password" send "passwd *** \ r" trusted CT "ftp>" send "hash \ r" reverse CT "* ftp> *" send "put $ file \ n" reverse CT "* ftp> *" send "Bye \ r" reverse CT "* goodbye *" reverse CT eofexit
[Test]:./autoftp. Sh filename
[Effect]: Automatically log on to the FTP user "username ***" and upload the "FILENAME" file to the server.