美文网首页
iterm2实现快捷键登入服务器

iterm2实现快捷键登入服务器

作者: theache | 来源:发表于2020-02-27 09:26 被阅读0次

    1 在本地配置服务器别名

    编辑本地~/.ssh/config文件,写入别名,ip,端口,登入用户等信息

    Host ali
     User root
     HostName 47.102.194.1
     port 24
    

    保存之后尝试ssh alissh root@47.102.194.1 -p 24这两个是一样的效果。别名同样适用于scp互传文件。很方便的。

    2 密钥自动登入服务器

    配置iterm2

    20200226180340.png

    在iterm2下输入 control + command + 2即可登入服务器。

    3 输入密码登入服务器

    首先确保本地安装expect。然后在/usr/bin下新建autoLogin.sh

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

    在iterm2下输入 control + command + 2即可登入服务器。

    相关文章

      网友评论

          本文标题:iterm2实现快捷键登入服务器

          本文链接:https://www.haomeiwen.com/subject/dctthhtx.html