Skip to content

Quick connect SSH server, powered by Powershell.

License

Notifications You must be signed in to change notification settings

Pagliacii/QuickSSH

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuickSSH

Just for fun. Maintain the SSH servers list in a JSON file, and use command QuickSSH to select one to connect.

Usage

Download QuickSSH.ps1 to somewhere you like, and add this function below into your $PROFILE:

Function QuickSSH { Invoke-Expression "\path\to\QuickSSH.ps1" }
# Helpful functions
Function KillAgent { gpg-connect-agent killagent /bye }
Function RunAgent { gpg-connect-agent /bye }

Reopen your Powershell and enter QuickSSH, it will work correctly!

  1. Connect
PS > QuickSSH
Load servers from /path/to/servers.json

Select one option below:
  [0] foo => [email protected]:11111
  [1] bar => [email protected]:22222
  [N] Create a new connection.
  [R] Remove a connection.
  [Q] Quit.

Select[default = N]: 0

Write to file: /path/to/servers.json
Done.

Connect to [email protected]:11111
Touch your smark key to auth when its light was blink:
  1. Add a new connection
PS > QuickSSH
Load servers from /path/to/servers.json

Select one option below:
  [0] foo => [email protected]:11111
  [1] bar => [email protected]:22222
  [N] Create a new connection.
  [R] Remove a connection.
  [Q] Quit.

Select[default = N]:

Please fill the fields of new connection:
> Name of connection: Baz
> Username: baz
> Hostname: 123.123.123.123
> Port[default = 22]: 33333
> New Connection: Baz=>[email protected]:33333

Write to file: /path/to/servers.json
Done.

Connect to [email protected]:33333
Touch your smart key to auth when its light was blink:
ssh: connect to host 123.123.123.123 port 33333: Connection refused
  1. Remove a connection and quit
PS > QuickSSH
Load servers from /path/to/servers.json

Select one option below:
  [0] Baz => [email protected]:33333
  [1] foo => [email protected]:11111
  [2] bar => [email protected]:22222
  [N] Create a new connection.
  [R] Remove a connection.
  [Q] Quit.

Select[default = N]: R

Enter number to remove: 0
Remove: Baz=>[email protected]:33333

Write to file: /path/to/servers.json
Done.

Select one option below:
  [0] foo => [email protected]:11111
  [1] bar => [email protected]:22222
  [N] Create a new connection.
  [R] Remove a connection.
  [Q] quit.

Select[default = N]: Q

See you.

Test Environment

Entry Value
OS Windows 10
Shell Powershell(v6.2.1) + oh-my-posh + posh-git
Terminal Microsoft Terminal
Others Gpg4win + Cygwin/SSH

Integration with Microsoft Terminal

Add code below into profiles.json > [ ] profiles:

        {
            "acrylicOpacity": 0.8,
            "closeOnExit": true,
            "colorScheme": "One Half Dark",
            "commandline": "pwsh -File path-to-QuickSSH.ps1",
            "cursorColor": "#FFFFFF",
            "cursorShape": "emptyBox",
            "fontFace": "Hack NF",
            "fontSize": 14,
            "guid": "{Custom GUID}",
            "historySize": 9001,
            "icon": "path-to-icon-file",
            "name": "QuickSSH",
            "padding": "10, 10, 10, 10",
            "snapOnInput": true,
            "useAcrylic": true
        },

Screenshots

screenshot1

screenshot2

screenshot3

Note

  1. If you don't use the smart key to auth, comment these lines in the script:
Function ConnectBySSH {
    ...
    # Comment >> Println "Touch your smart key to auth when its light was blink: "
    ...
}
Function Main {
    ...
    # Comment >> $ENV:SSH_AUTH_SOCK = "<your-custom-variable>"
    ...
}
  1. If connect failed, just restart the gpg-agent:
PS > KillAgent
OK closing connection
PS > RunAgent
gpg-connect-agent: no running gpg-agent - starting 'path-to-gpg-agent'
gpg-connect-agent: waiting for the agent to come up ... (5s)
gpg-connect-agent: connection to agent established
  1. If you want to use Cygwin/SSH, remove %WINDIR%\System32\OpenSSH from environment variables.

  2. Generate a new GUID by Powershell:

PS > [GUID]::NewGuid()

Guid
----
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

About

Quick connect SSH server, powered by Powershell.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published