36

用 Windows Terminal 替换你的盗版远程管理软件?

 4 years ago
source link: https://mp.weixin.qq.com/s/RCeDVZstRAisFpnXG3UAnQ
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

前言

作为开发或者是运维的角色,必不可少的是使用一些远程管理工具。常见的有putty,XShell,SecureCRT, MobaXterm。这些软件中一些商业软件还需要付费,盗版也会带来一些知识产权之类的纠纷。因此为了规避使用盗版软件,我会把目光会投向开源工具,平时我做这种远程linux管理使用的putty+ supper putty(多putty session管理)的组合,用起来也相当不错。但是因为是开源,所以还是会有些简陋,定制化的余地不多。

如果你是Mac 机器的话,Mac OS天然的就有终端的功能去远程到linux机器之上,而windows一直需要第三方的方式去管理,这一点也被众多开发人员所诟病。

微软这些年也是对开发人员更加重视,不再是高高在上,而是主动迎合开发人员。这些年一系列的举动,例如收购Github,发布了WSL,windows terminal等工具。微软在用自家的生态去和广大开发人员去建立联系,本文介绍的windows terminal就是其中一个具有很高口碑的工具。让你使用原生的windows即可管理你远程的机器。

介绍

前不久,也就是2020年5月19日,微软正式发布Windows Terminal 1.0。这个在2019年发布的工具在1年多的时间里提供了相当成熟的用户体验。1.0版本的发布让这个产品真正成为windows产品系列里重要的一员。这个版本在7月份之后会进行月度的更新,到时候我们会看到更多的功能会集成进来。

Windows Terminal 提供了以下重要特性:

  • 标签化管理会话

  • 对不同的profile进行自定义,灵活的主题,样式,背景,字体配置

  • GPU加速渲染,更流畅的显示体验

Ibuiqqa.gif

安装:

安装windows terminal有两个途径

  • 从windows 应用商店下载

BRnyAfY.png!web

  • 从Github上下载相应的release

vIzuiyb.png!web

安装完成后可以打开界面如下:

r2Arm2f.png!web

界面中是以标签的形式保存各种会话。从打开的界面来看似乎与传统的cmd或者powershell没什么区别,只是使用了多标签的方式去管理了。也并没看到其强大的功能。

下面我们来进行定制化的配置,用于远程到一台linux主机之上。

配置

点击"设置"按钮,其实就是打开了一个文本文件叫settings.json。熟悉VS Code的人知道其实微软通过这种文本配置的方式进行定制化配置,而不是采用我们熟悉的UI交互的方式。这种方式更加贴近开发人员的操作习惯,也便于用户存储相应的配置信息到文本,或者是备份配置信息。

q6ziyyr.png!web

具体的配置的含义大家可以参考文章:

https://github.com/microsoft/terminal/blob/master/doc/cascadia/SettingsSchema.md

按住“alt”键点击“设置”按钮则可以看到默认的配置都有那些,我们可以对照上面的schema的配置,来自定义我们的配置信息。

我这里粘贴出我自己的配置文件

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation

{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",

    "profiles":
    {
        "defaults":
        {
            // Put settings here that you want to apply to all profiles
            // "colorScheme": "Custom"
        },
        "list":
        [
            {
                // Make changes here to the powershell.exe profile
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "powershell.exe",
                "hidden": false
            },
            {
                // Make changes here to the cmd.exe profile
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "cmd",
                "commandline": "cmd.exe",
                "hidden": false
            },
            {
                 "guid": "{9eb270e1-5f84-4a4f-9bc4-c6be05f7c9fa}",
                 "name": "linux机器",
                 "commandline": "ssh [email protected]",
                 "useAcrylic": true,
                 "acrylicOpacity": 0.9,
                 "icon": "C:\\Users\\floyd\\Documents\\terminal.ico",
                 "backgroundImage": "C:\\Users\\floyd\\Pictures\\高清壁纸\\ChMkJlwPkDyIMVoRAAKobrmGR9sAAttDQGW9T4AAqiG750.jpg",
                 "backgroundImageStretchMode": "uniformToFill",
                 "backgroundImageOpacity": 0.1,
                 "colorScheme": "Dark Pastel"
             }
        ]
    },

    // Add custom color schemes to this array
    "schemes": [
         {
          "name": "Dark Pastel",
          "black": "#000000",
          "red": "#ff5555",
          "green": "#55ff55",
          "yellow": "#ffff55",
          "blue": "#5555ff",
          "purple": "#ff55ff",
          "cyan": "#55ffff",
          "white": "#bbbbbb",
          "brightBlack": "#555555",
          "brightRed": "#ff5555",
          "brightGreen": "#55ff55",
          "brightYellow": "#ffff55",
          "brightBlue": "#5555ff",
          "brightPurple": "#ff55ff",
          "brightCyan": "#55ffff",
          "brightWhite": "#ffffff",
          "background": "#000000",
          "foreground": "#ffffff"
      }
    ],

    // Add any keybinding overrides to this array.
    // To unbind a default keybinding, set the command to "unbound"
    "keybindings": []
}

这里我们主要配置了一个远程linux的profile

{
    "guid": "{9eb270e1-5f84-4a4f-9bc4-c6be05f7c9fa}",
    "name": "linux机器",
    "commandline": "ssh [email protected]",
    "useAcrylic": true,
    "acrylicOpacity": 0.9,
    "icon": "C:\\Users\\floyd\\Documents\\terminal.ico",
    "backgroundImage": "C:\\Users\\floyd\\Pictures\\高清壁纸\\ChMkJlwPkDyIMVoRAAKobrmGR9sAAttDQGW9T4AAqiG750.jpg",
    "backgroundImageStretchMode": "uniformToFill",
    "backgroundImageOpacity": 0.1,
    "colorScheme": "Dark Pastel"
}

guid: 需要用户指定一个唯一的ID,大家可以在网上找任意一个guid的生成器生成,仅用作唯一标识

commandline:用于远程ssh命令的配置,这里我们使用ssh

useAcrylic&acrylicOpacity:用于配置窗口的透明度的那种毛玻璃效果

icon:用于在tab页显示icon

backgroundImage&backgroundImageStretchMode&backgroundImageOpacity:用于配置窗口的背景图片以及透明度等配置,这里我们指向一个高清壁纸

colorScheme:用于指定不同的颜色主题,这里我们在schemas里面配置了一种颜色主题Dark Pastel

配置结束后,我们就可以在界面上找到我们配置好的项目:

ZzQnQfa.png!web

点击后输入密码即可访问该机器了:

iQvmMr2.png!web

在settings.json中做一个简单的更改例如修改背景透明度 0.1 ->  0.9

"backgroundImageOpacity": 0.1,

to

"backgroundImageOpacity": 0.9,

保存后效果实时显示:

nEreeyi.png!web

总结

本文简单介绍了使用windows terminal进行远程linux服务器的访问。大家可以自定义的空间很大,可以通过配置,变成你更趁手的远程管理工具。希望未来有更多新的功能集成到终端之上。

windows 终端官方文档: https://docs.microsoft.com/zh-cn/windows/terminal/

Github地址: https://github.com/microsoft/terminal


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK