In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you about how to use the mac computer to automatically log on to the server. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Implementation of mac computer automatic login server with Iterm+expect
Expect is an automatic interaction suite, which is mainly used in the execution of commands and programs, the system is required to input a specified string in the form of interaction to achieve interactive communication. Its automatic interaction process is as follows:
Spawn starts the specified process-> expect gets the specified keyword-- > send sends the specified character to the specified program-> execution completes the exit
Next we will use expect to implement automatic login for ssh. First, create a new file / usr/local/bin/iterm2Login.sh with the following contents:
#! / usr/bin/expectset timeout 30set host [lindex $argv 0] # this line is to set a variable. The variable name can be as meaningful as possible, followed by the passed parameter, and 0 represents the first parameter, which will be used later. Set port [lindex $argv 1] set user [lindex $argv 2] set pswd [lindex $argv 3] spawn ssh-p $port $user@$host # spawn is an internal command of the expect environment. Its main function is to add a shell to the ssh running process to pass interactive instructions. Expect {"(yes/no)?" {send "yes\ n"; exp_continue;}-re "(p | P) ass (word | wd):" {send "$pswd\ n"} # expect is also an internal command in the expect environment, which is used to determine whether the output after the last instruction input contains the string in "" double quotes, and-re indicates that it is matched by regularity. # if you log in for the first time, the string "yes/no" will appear, send the (send) instruction "yes\ r", and then continue (exp_continue). Interact# interact: maintain the interactive state after the execution is completed, and hand over control to the console.
The three parameters argv 0, argv 1, argv 2, and argv 3 are ip, port number, user name and password in turn.
Give the script execution permissions:
$sudo chmod + x / usr/local/bin/iterm2Login.sh
Replace the Command part of Profile with login through the script above:
Export LC_CTYPE=en_US;/usr/local/bin/iterm2Login.sh 172.16.2.84 22 root "1"
Add regular expression
Regular expression: Are you sure you want to continue connecting (yes/no)? Action: Send TextParameters: yes\ rInstant: checked
Then you can log in to the server automatically.
Using Zmodem to realize fast file transfer
Lrzsz software packages are required on both the server and the mac computer.
# centos & & RHELyum-y install lrzsz# Ubuntu & & Debianapt-get install lrzsz# Mac osbrew install lrzsz configure iTerm2
On Github, the world's largest same-sex dating site, a project called ZModem integration for iTerm 2 has been shared. We can easily support Zmodem on iTerm2 by downloading the corresponding script and simply configuring it.
Project address: https://github.com/kuoruan/iterm2-zmodem[2]
Download and install the script
$wget-qO / usr/local/bin/iterm2-zmodem.sh https://github.com/kuoruan/iterm2-zmodem/raw/master/iterm2-zmodem.sh$ chmod + x / usr/local/bin/iterm2-zmodem.sh
Configure triggers on iTerm2
Open iTerm2 and click Preferences → Profiles to select the specified Profile. Then continue selecting Advanced → Triggers and click Edit to add two triggers.
Add two triggers as follows, first adding triggers for the sz instruction:
Regular expression: rz waiting to receive.\ *\ * B0100Action: Run Silent CoprocessParameters: / usr/local/bin/iterm2-zmodem.sh sendInstant: checked
Secondly, add the trigger of the rz instruction:
Regular expression:\ *\ * B00000000000000Action: Run Silent CoprocessParameters: / usr/local/bin/iterm2-zmodem.sh recvInstant: checked
Successfully increase the effect after completion, similar to the following figure:
The purpose of configuring these two triggers is to have iTerm2 invoke the corresponding send and receive scripts through the specified trigger based on the characters displayed on the terminal.
The above is the editor for you to share how to use the mac computer to automatically log on to the server, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.