首页 系统相关 正文
  • 本文约422字,阅读需2分钟
  • 12
  • 0

mac登录远程服务器脚本汇总

摘要

用户名密码登录 脚本代码 #!/usr/bin/expect set user 用户名 set password 密码 spawn ssh ${user}@服务器1地址 expect yes/no {send yes\n} expect password {send ${password}\r;} expect *# {send 登录服务器:服务器1...

用户名密码登录

脚本代码

#!/usr/bin/expect

set user "用户名"
set password "密码"

spawn ssh ${user}@服务器1地址
expect "*yes/no*" {send "yes\n"}
expect "*password*" {send "${password}\r;"}
expect "*#" {send "登录服务器:服务器1地址  跳转 ssh root@服务器2地址  密码:${password}"}
interact  #这个是释放操作

证书登录

#!/bin/bash

ssh -i 证书地址 root@服务器地址

mac修改

##配置脚本
alias loginServer="文件路径/xxx.sh"

mac 添加环境变量

##以go环境变量添加为例
export GOROOT=/usr/local/go
export GOPATH=~/go
export PATH="$GOROOT/bin:$PATH"
export PATH="$GOPATH/bin:$PATH"
    评论
    更换验证码
    友情链接