The technology stack is VUE

Connecting to the Remote Server

1. Create an Expect script file in a directory, such as your. SSH directory:

    cd ~/.ssh
    sudo touch centos7
    sudo vim centos7
Copy the code

2. Write the following content:

#! /usr/bin/expect -f set user xxx set password xxxxx set host xxxxx set port 22 set timeout -1 spawn ssh $user@$host expect "*assword:*" send "$password\r" interact expect eofCopy the code

3. Go to iterm2->preference-> Profiles and create a login label

4. Go to iterm2->profiles-> corresponding configuration

Rz uploads files

Brew install LRZSZ 2. Create the iterm2-recv-zmodem.sh and iterm2-send-zmodem.sh files vi iterm2-recv-zmodem.sh vi iterm2-send-zmodem.sh Iterm2-recv-zmodem. sh contains the following information:

#! /bin/bash # Author: Matt Mastracci ([email protected]) # AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script # licensed under cc-wiki with attribution required # Remainder of script public domain #COMMAND=$(which rz) if [[ -f /opt/homebrew/bin/rz ]]; then COMMAND=/opt/homebrew/bin/rz else COMMAND=/usr/local/bin/rz fi osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm if [[ $NAME = "iTerm" ]]; then FILE=$(osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")") else FILE=$(osascript -e 'tell application "iTerm2" to activate' -e 'tell application "iTerm2" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")") fi if [[ $FILE = "" ]]; then echo Cancelled. # Send ZModem cancel echo -e \\x18\\x18\\x18\\x18\\x18 sleep 1 echo echo \# Cancelled transfer else  cd "$FILE" $COMMAND --rename --escape --binary --bufsize 4096 sleep 1 echo echo echo \# Sent \-\> $FILE fiCopy the code

Iterm2-send-zmodem. sh contains the following information:

### # @Author: your name # @Date: 2019-12-11 01:03:06 # @LastEditTime: 2019-12-11 01:03:21 # @LastEditors: your name # @Description: In User Settings Edit # @FilePath: /rzsz/iterm2-send-zmodem.sh ### #! /bin/bash # Author: Matt Mastracci ([email protected]) # AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script # licensed under cc-wiki with attribution required # Remainder of script public domain #COMMAND=$(which sz) if [[ -f /opt/homebrew/bin/sz ]]; then COMMAND=/opt/homebrew/bin/sz else COMMAND=/usr/local/bin/sz fi osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm if [[ $NAME = "iTerm" ]]; then FILE=$(osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")") else FILE=$(osascript -e 'tell application "iTerm2" to activate' -e 'tell application "iTerm2" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")") fi if [[ $FILE = "" ]]; then echo Cancelled. # Send ZModem cancel echo -e \\x18\\x18\\x18\\x18\\x18 sleep 1 echo echo \# Cancelled transfer else  $COMMAND "$FILE" --escape --binary --bufsize 4096 sleep 1 echo echo \# Received "$FILE" fiCopy the code

3. Set file permissions chmod a+x /usr/local/bin/iterm2-recv-zmodem.sh /usr/local/bin/iterm2-send-zmodem.sh

Open the Preferences for iterm2 (shortcut command+,) and then Profiles->Default->Advanced->Triggers->Edit enter the editing interface.

Click the plus button in the lower left corner of the Triggers screen to create two lines of Regular Expression: RZ Waiting to receive.**B0100 and **B00000000000000, respectively. Action Select Run Silent Coprocess… , Parameters are /usr/local/bin/iterm2-send-zmodem.sh and /usr/local/bin/iterm2-recv-zmodem.sh respectively

Enter Rz on iTerm2, the access will pop up automatically, and then select the file to upload. Sz to download.

Rz upload failed

Expect automatically connects to the server, and RZ uploads fail.

  1. Log in to the server using SSH as follows:

  1. Enter the password to upload