A script to manage ssh/config
- Put a configuration file at
~/.ssh/pssh/.ssh-config
- Install it :
pssh install
## Variable
$DO_PKEY=~/.ssh/key/do/d1_id_rsa
$VPS_COMMON_OPTION = {
PubkeyAuthentication yes
Protocol 2
ForwardX11 no
}
@@ GITHUB : Every Comment will be conserved;
+---------------+------------------+---------------------------------------+ # This is dummy lines, be ignored.
| github-user1 | [email protected] | ~/.ssh/key/github/github_user1_id_rsa | # This comment will be placed before this line.
| github-user2 | [email protected] | ~/.ssh/key/github/github_user2_id_rsa |
+---------------+------------------+---------------------------------------+ # This is dummy lines, be ignored.
@@ DO at amsterdam
+-------+---------------------------+------------+
| d1 | [email protected] | $DO_PKEY | $VPS_COMMON_OPTION
| d2 | [email protected] | $DO_PKEY | $VPS_COMMON_OPTION
+-------+---------------------------+------------+
# Without pkey but with variabled option
+-------+---------------------------+------------+
| d4 | [email protected] | x | $VPS_COMMON_OPTION # "x" should be instead of empty space.
+-------+---------------------------+------------+
+-------+---------------------------+------------+
| d4 | [email protected] | | # You don't need "x" without 4th field.
$VPS_COMMON_OPTION
ForwardX11 yes # .ssh/config format is always avaiable in the place
+-------+---------------------------+------------+
# Usual .ssh/config format is available
Host *
Protocol 2
IdentityFile ~/.ssh/key/id_rsa
ControlMaster auto
ControlPath ~/.ssh/controlmasters/%r@%h:%p
ControlPersist 1h
- All files are under ~/.ssh/pssh ( essentialy just a .ssh-config )
$ pssh -h
# usage : pssh <command> <options>
# Commands
cat : Print Pssh config file with grep
usage: pssh cat [string to grep]
edit : Edit Pssh config file
install : Install Pssh config file to /home/pung96/.ssh/config
key_deploy : Deploy pub key to ssh server : pssh key_deploy <server> <file>
list : Host List
usage: pssh list [string to grep] [-g [group index]] [-G [grep in groups]]
-g withoud 'group index' will list only a group list
-G will grep group names and inline comments and print with it's hosts
path : Print Path of pssh directory
test : Compile /home/pung96/.ssh/pssh/.ssh_config and print on screen
# Options
-c --config : Use custom pssh config file
-h --help : Display Help
-b : display without color
-g --group : group option for list
-G : group option for list
-
NOTE :
edit
doesn't mean installing after edit. One needs additional call ofpssh install
to apply changes. -
Bash completion
echo 'eval $(pssh bash_completion_template)' >> ~/.bash_profile
- NOTE : You may need an additional path in advance.
The configuration formate is super-set of .ssh/config
format. So you can put every raw configurations in .ssh-config
But if any line begin with |
, $
,+
or -
, they will be translated by pssh
formater.
-
A line begins with
Begins with RegExp Descriptions +
/^\s*\+/
Ignore a line. |
/^\s*|/
Parse a line as an entry
$
/^\s*\$/
Parse a line as variable
(both of definition or using)-
/^\s*\-/
Remove until -
and leave a line there@@
/^\s*@@/
Group others Just leave it as it is White spaces before triggers are allowed
-
Variable
- If a
variable
comes before=
in a line (/^\s*\$.*=/
), it's adefinition
- Otherwise a
using
, so just translated to a content
- If a
-
Entry
- After first
|
, all following|
s are dealt as spaces - Include first
#
, all followings arecomments
. They will be placed before the line. - fields are
| alias | user@server:port | key | options
- After first
- more on https://github.com/qgp9/pssh/blob/master/example/.ssh_config
- and compiled
config
bypssh test
https://github.com/qgp9/pssh/blob/master/example/config