ServerConnector
Do you need to ssh/sftp into servers and get tired of always typing ssh user@some-connection.org
? Or worse having to type an IP address?, (*1)
This console application will allow you to define connections you make frequently to connect as easy as connect e
, (*2)
Install
Using Composer, (*3)
$ composer global require taylornetwork/server-connector
Config
Config files will be published to ~/ServerConnector/config/
, (*4)
Note: if config files are not automatically published run the config:publish
command., (*5)
$ server-connector config:publish
defaults.php
Defines the default connection type if omitted., (*6)
// defaults.php
return [
'type' => 'ssh',
];
connections.php
This is where you define all your server connections., (*7)
By default:, (*8)
// connections.php
return [
// Name of the connection as the key
'example' => [
// Add any short aliases to access this as
'aliases' => [ 'ex', 'e' ],
// Add credentials here, or an empty array
'credentials' => [
'username' => 'user1',
// Password is not recommended, ideally omit this and use ssh keys
'password' => 'password1',
],
// Omit to use default or you can set the path to a private key
'keyFile' => '~/.ssh/id_rsa',
// URL or IP address to connect to
'url' => 'connect.example.com',
],
];
Add your connections in the array that will be returned., (*9)
Usage
Once you have defined some connections you can run, (*10)
$ server-connector connect ConnectionNameOrAlias
Which will connect to the connection with the default connection type, (*11)
Alternatively, (*12)
$ server-connector connect sftp ConnectionNameOrAlias
To connect via SFTP if it isn't the default., (*13)
Register BASH Function
To add a function to your ~/.profile
to call server-connector
you can use, (*14)
$ server-connector register
By default it will register a function connect()
in your ~/.profile
you can specify the function name by, (*15)
$ server-connector register FunctionName
After running this command you will need to source your ~/.profile
or restart your terminal application., (*16)
With the BASH function you can call this application by, (*17)
connect ConnectionNameOrAlias