0%

在Mac中添加快速ssh

每天一个小技巧——快乐高效干到老
在Mac自带的terminal中访问ssh的时候都需要打冗长的命令(如下),而且hostname一般不容易记忆。

1
~$ ssh root@192.168.5.100

为了结局如下困扰,可以采取如下方法:

  1. 创建或者访问 config
    1
    ~$ vim ~/.ssh/config
  2. 编辑config
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # 服务器1
    host zz
    hostname IP地址
    port 22
    user 用户名

    # 服务器2
    host 别名
    hostname IP地址
    port 22
    user 用户名
  3. 直接访问 别名 即可
    1
    ~$ ssh zz	
    image-20201228105648592