Alfred 配置 Secure SHell 工作流

免密码登录

生成公钥和私钥:

ssh-keygen

默认会使用 RSA 非对称加密算法,生成私钥 ~/.ssh/id_rsa 文件和公钥 ~/.ssh/id_rsa.pub 文件。
拷贝公钥到目标主机:

ssh-copy-id -i ~/.ssh/id\_rsa.pub @

输入目标主机密码,完成。

安装

下载
并导入工作流。
Secure SHell 特性:

  • 自动提示主机名;
  • 记住用户名;
  • 支持以下源:

    ~/ssh/config
    ~/ssh/known_hosts
    /etc/hosts
    /etc/ssh/ssh_config
    

启动 Alfred,输入关键字 ssh

集成 iTerm2

打开 Alfred Preferences -> Features -> Terminal / Shell,下拉选项 Application 选择 Custom。
替换以下脚本:

-- This is v0.7 of the custom script for AlfredApp for iTerm 3.1.1+
-- created by Sinan Eldem www.sinaneldem.com.tr

on alfred_script(q)  
    if application "iTerm2" is running or application "iTerm" is running then
        run script "
            on run {q}
                tell application \"iTerm\"
                    activate
                    try
                        select first window
                        set onlywindow to true
                    on error
                        create window with default profile
                        select first window
                        set onlywindow to true
                    end try
                    tell the first window
                        if onlywindow is false then
                            create tab with default profile
                        end if
                        tell current session to write text q
                    end tell
                end tell
            end run
        " with parameters {q}
    else
        run script "
            on run {q}
                tell application \"iTerm\"
                    activate
                    try
                        select first window
                    on error
                        create window with default profile
                        select first window
                    end try
                    tell the first window
                        tell current session to write text q
                    end tell
                end tell
            end run
        " with parameters {q}
    end if
end alfred_script

打开 iTerm2 Preferences -> Profiles,新建 Profile,下拉选项 URL Schemes 选择 ssh。