使用 Toilet 生成 SSH banner

toilet Jun 22, 2017

无事水一发。

以前登录远程服务器,欢迎信息都在过于单调了,于是想要生成一些有意思的画面显示出来。

网上搜索了一下,找到了 Toilet 这个 ASCII Art 软件。

安装很简单的不用多说了, sudo apt-get install toilet

安装完成之后输入 toilet -h,先看看使用说明。

$ toilet -h

  -f, --font <name>        select the font
  -d, --directory <dir>    specify font directory
  -s, -S, -k, -W, -o       render mode (default, force smushing,
                           kerning, full width, overlap)
  -w, --width <width>      set output width
  -t, --termwidth          adapt to terminal's width
  -F, --filter <filters>   apply one or several filters to the text
  -F, --filter list        list available filters
      --gay                rainbow filter (same as -F gay)
      --metal              metal filter (same as -F metal)
  -E, --export <format>    select export format
  -E, --export list        list available export formats
      --irc                output IRC colour codes (same as -E irc)
      --html               output an HTML document (same as -E html)
  -h, --help               display this help and exit
  -I, --infocode <code>    print FIGlet-compatible infocode
  -v, --version            output version information and exit
Usage: toilet [ -hkostvSW ] [ -d fontdirectory ]
              [ -f fontfile ] [ -F filter ] [ -w outputwidth ]
              [ -I infocode ] [ -E format ] [ message ]

第一个是字体选择,toilet 使用的字体文件存放于 /usr/share/figlet,所以直接写了一个小脚本来看看不同字体的显示效果:

for filename in `ls /usr/share/figlet`
do
    echo "font: ${filename%.*}\n"
    toilet -f ${filename%.*} -w 200 "MOEOVERFLOW"
done

输出结果

toilet-font-review-1
toilet-font-review-2
toilet-font-review-3
toilet-font-review-4

另外你也可以使用一些过滤器加上色彩:

$ toilet --filter list

Available filters:
"crop": crop unused blanks
"gay": add a rainbow colour effect
"metal": add a metallic colour effect
"flip": flip horizontally
"flop": flip vertically
"180": rotate 180 degrees
"left": rotate 90 degrees counterclockwise
"right": rotate 90 degrees clockwise
"border": surround text with a border

toilet-font-review-5

不过这个 --gay 的预置色彩选项和名字...

好好的用 --rainbow 不行么...

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.