Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 1.65 KB

subprocess_curses_and_regexp.md

File metadata and controls

65 lines (48 loc) · 1.65 KB

Curses based ssh config file viewer

Useful information

Study following links:

Subtask 1

Create utility which shows Host entries from ~/.ssh/config file using curses interface and opens connection to selected Host by pressing Enter or o keys.

Some notes about implementation:

  • Uses system ssh command.
  • Supports vim-like motion (j, k).
  • Open ssh connection via user shell.

For example, your ~/.ssh/config contains following entries:

$ cat ~/.ssh/config
Host *
    ServerAliveInterval 300
    ServerAliveCountMax 2

Host cobbler
    IdentityFile ~/.ssh/cobbler.id_rsa
    User cobbler
    Hostname 10.10.10.1

Host jenkins
    User jenkins
    Hostname 10.10.10.2
    IdentityFile ~/.ssh/jenkins.id_rsa

Host git
    Hostname 10.12.13.2
    IdentityFile ~/.ssh/git.id_rsa

Host minion1
    Hostname salt-minion1.int.example.com
    User root

Host minion2
    User root
    Hostname salt-minion2.int.example.com

The simplified screen of your curses application might look like: SSH viewer

Usage case

  1. User starts script in a Linux termnal.
  2. Using j or k keys selects required row with host entry.
  3. Pressing Enter or o keys opens remote session using system ssh command.
  4. System ssh command uses section from ~/.ssh/config file.