关于iterm2:Iterm2-JumpServer-自动登录脚本

本地连接远端的服务器,Iterm2 能够说是MAC 上的一大利器了,配合脚本,能够一键直连服务器 最近因公司增强了服务器登陆验证,换了JumpServer 服务器,还减少了二次认证,必须用Google Authenticator输出6位动静验证码,能力胜利登陆,这样的话每次都得关上手机,手动输出验证码比拟麻烦,所以,我这么懒的程序猿怎么会安分的一步步操作呢,来个脚本 开始之前,先查看你的电脑装没装brew 和 expect,如果没有装置,先装完再进行后续步骤哈 装置brew /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" speed装置expectbrew install expect 筹备工作就绪,咱们持续接下来的步骤 1、首先,给你的电脑装一个 oath-toolkitbrew install oath-toolkit2、你还得获取到我下面截图的二维码上面的 Secret 前面的 key,用上面的命令验证一下你设置的对不对吧oathtool --totp -b YOUR-PRIVATE-KEY3、如果下面的都没有问题,间接来上脚本 #!/usr/bin/expectset jumpusr user_nameset pwd passwordset jumphost 172.16.XXX.XXset host [lindex $argv 0]catch {spawn ssh -p 22 $jumpusr@$jumphost}expect "*password:*"send "$pwd\r"expect "*MFA*" { set code [exec sh -c {oathtool --totp -b YOUR-PRIVATE-KEY}] send "$code\r"}expect {"*Opt>*" { send "[lindex /$argv 0]\r";exp_continue}"*Host*" { send "1\r1\r"}}# 此处看运维给你的什么权限,间接进入app的话上面的能够删除expect "*$*" { send "sudo su - app\r"}interact

July 7, 2022 · 1 min · jiezi

关于iterm2:快速配置-iTerm2GitNode

iTerm2+Git+Node 配置iTerm2 配置装置 iTerm2配置主题 oh-my-zsh sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"主动高亮插件 cd ~/.oh-my-**zsh**/plugins/git clone https://github.com/zsh-users/zsh-syntax-highlighting.gitvi ~/.zshrc 并增加到最初: source ~/.oh-my-zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh保留退出并执行 source ~/.zshrc 主动补全插件 cd ~/.oh-my-zsh/plugins/git clone https://github.com/zsh-users/zsh-autosuggestionsvi ~/.zshrc 并批改 plugins=(zsh-autosuggestions git)保留退出并执行 source ~/.zshrc 配置默认文件夹iTerm2->Preferences->Profiles->General->Working Directory->Directory输出默认文件夹门路 Git 配置装置Homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"装置 Git brew install git配置 user.name 和 user.email git config --global user.name "username"git config --global user.email "useremail"配置 alias 节省时间 git config --global alias.st statusgit config --global alias.co checkoutgit config --global alias.ci commitgit config --global alias.br branchgit config --global alias.pl pullgit config --global alias.ps pushNode 配置下载 Node 并装置:https://nodejs.org/配置淘宝镜像源 ...

November 4, 2021 · 1 min · jiezi