Everyone knows to use the ITerm2 connection shh use the command SSH-P22 [email protected], and then enter the password.
But it's still a bit cumbersome to enter every time. ITERM2 provides a quick way for us. Three steps to complete this setting. Here's how:
1, Edit command text
Sample:
[Plain]View PlainCopy
- #!/usr/bin/expect-f
- Set User root
- Set Host 172.16.10.71
- Set Password mima123456
- Set Timeout-1
- Spawn ssh [email protected] $host
- Expect "*assword:*"
- Send "$password \ r"
- Interact
- Expect EOF
According to this sample, write a text file to be saved in one place.
The port number is not specified in this sample and is using SSH default port 22
If it is a different port number, you can modify it as follows
[Plain]View PlainCopy
- #!/usr/bin/expect-f
- Set Port 2121
- Set User root
- Set Host 172.16.10.71
- Set Password mima123456
- Set Timeout-1
- Spawn Ssh-p$port [email protected] $host
- Expect "*assword:*"
- Send "$password \ r"
- Interact
- Expect EOF
Syntax Description: The above set is the definition variable
The spawn below is the call command, which uses the above defined variables in the command
2, set invoke command
ITerm--Preferences open the Settings screen
Click the lower left corner + add a shortcut,
Select Commond on the right and enter the address of the command file in the input box
Give the shortcut a name above the right.
This completes the setup of the shortcut.
3, using shortcuts
Start ITerm2 software, will pop up a selection of shortcut interface, select the pre-built shortcuts can be;
Already opened ITerm2, right-click on the Software icon and select New Table to see the pre-built shortcuts.
Use ITerm2 to connect SSH quickly