Développement web - Configuration Iterm2 Utilisation rapide SSH (mac)

Adresse de téléchargement officielle d'Iterm2 : https://item2.com/downloads.html

Ou installez Homebrew, ouvrez le terminal, entrez la commande suivante et appuyez sur Entrée :

brew install iTerm2  

Iterm2 configure SSH pour une utilisation rapide

Créez d'abord un script shell pour vous connecter au serveur

#创建一个文件夹(自定义)专门用于存放脚本 并cd到该目录下
#我的文件夹路径是/Users/wangjiabao/environment/iterm2/ConnectToServerByScript
cd /Users/wangjiabao/environment/iterm2/ConnectToServerByScript
 
#创建myserver.sh文件
touch config.sh

#编辑myserver.sh文件
vi config.sh

Entrée clavier i pour éditer le fichier, insérez le contenu suivant :

#!/usr/bin/expect
set timeout 30
spawn ssh -p [lindex $argv 0][lindex $argv 1]@[lindex $argv 2]
expect {"(yes/no)?"{send "yes\n";exp_continue}"password:"{send "[lindex $argv 3]\n"}}
interact

Explication des variables dans le fichier :

[lindex $argv 0] =>端口号
[lindex $argv 1] =>服务器用户名
[lindex $argv 2] =>服务器IP地址
[lindex $argv 3] =>服务器密码

Une fois l'insertion terminée, appuyez sur esc et entrez : wq pour quitter, puis accordez l'autorisation au fichier

chmod 777 config.sh

Ouvrez iTerm2, ouvrez l'interface de configuration des Préférences, Profils -> général, cliquez sur le signe + dans le coin inférieur gauche, créez un nouveau profil, reportez-vous à l'image ci-dessous et entrez le contenu dans la position correspondante.

Le contenu de Envoyer le texte au début est le suivant :

/Users/wangjiabao/environment/iterm2/ConnectToServerByScript/config.sh 22 root 192.168.1.111 xxxxxxx

Tout de suite

脚本路径 端口号 用户名 IP地址 密码

Une fois la configuration terminée, le nom du fichier de configuration s'affichera ici, cliquez pour vous connecter automatiquement au serveur distant.

Je suppose que tu aimes

Origine blog.csdn.net/weixin_41606115/article/details/129127937
conseillé
Classement