So I returned to the use of Linux command line terminals, by creating multiple alias to meet the different SSH parameters, such as some need to use key, some need to use a password, and then add all the servers to a text file in a list of the way to update, It also feels good to use the content as a list of these alias's automatic completion.
Specific configuration:
Define Alias
The code is as follows |
Copy Code |
[Dong.guo@heydevops ~]$ vim. BASHRC Alias sshads= ' ssh-t-i/home/dong.guo/workspace/sshkeys/key_adsymp-l adsymp ' Alias sshrootdraw= ' sshpass-p ' drawbridge ' ssh-l root ' Alias sshrootkey= ' ssh-t-i/home/dong.guo/workspace/sshkeys/key_root-l root ' Create the server list file and enter all server host names [Dong.guo@heydevops ~]$ head-n 10/home/dong.guo/workspace/autocomp/servers.list api1e api2e api3e c1e c2e c3e c4e c5e cb1e cb2e
|
Add the AutoComplete feature to the created alias Www.111cn.net
The code is as follows |
Copy Code |
[Dong.guo@heydevops ~]$ vim. BASHRC # Enable Auto-completion of servers via Sshads, Sshrootdraw and Sshrootkey function _servers () { Compreply= () Local Cur=${comp_words[comp_cword]}; Local Com=${comp_words[comp_cword-1]}; Case $com in ' Sshads ') Local servers= ($ (cat/home/dong.guo/workspace/autocomp/servers.list)) Compreply= ($ (compgen-w ' ${servers[@]} '--$cur)) ;; ' Sshrootdraw ') Local servers= ($ (cat/home/dong.guo/workspace/autocomp/servers.list)) Compreply= ($ (compgen-w ' ${servers[@]} '--$cur)) ;; ' Sshrootkey ') Local servers= ($ (cat/home/dong.guo/workspace/autocomp/servers.list)) Compreply= ($ (compgen-w ' ${servers[@]} '--$cur)) ;; Esac } Complete-f _servers Sshads Complete-f _servers Sshrootdraw Complete-f _servers Sshrootkey Make configuration effective [Dong.guo@heydevops ~]$ Source BASHRC |
Gracefully tap the TAB key to experience the thrill of automatic completion,