mac 下使用 Shuttle 配合expect脚本使用ssh免输入密码登录

Shuttle是 https://github.com/fitztrev/shuttle 的免费开源软件。

使用expect脚本可以根据屏幕显示的要求自动输入相应的指令。

编写/data/ssh/ssh-server.sh

#!/usr/bin/expect

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

其中[lindex $argv 0] 表示提供的第一个参数,其他的以此类推

Shuttle配置:

{
  "_comments": [
    "Valid terminals include: 'Terminal.app' or 'iTerm'",
    "In the editor value change 'default' to 'nano', 'vi', or another terminal based editor.",
    "Hosts will also be read from your ~/.ssh/config or /etc/ssh_config file, if available",
    "For more information on how to configure, please see http://fitztrev.github.io/shuttle/"
  ],
  "editor": "default",
  "launch_at_login": false,
  "terminal": "Terminal.app",
  "iTerm_version": "nightly",
  "default_theme": "Homebrew",
  "open_in": "new",
  "show_ssh_config_hosts": false,
  "ssh_config_ignore_hosts": [],
  "ssh_config_ignore_keywords": [],
  "hosts": [
    {
      "cmd": "ssh-server.sh 22 root@192.168.5.10 pwd4root",
      "name": "测试SSH服务器"
    }]
}

保存后,使用Shuttle直接在菜单中选中“测试SSH服务器” 即可实现免输入密码登录.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值