taylornetwork/server-connector

v1.2 2022-11-21 15:24 UTC

This package is auto-updated.

Last update: 2024-03-21 18:15:28 UTC


README

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?

This console application will allow you to define connections you make frequently to connect as easy as connect e

Install

Using Composer

$ composer global require taylornetwork/server-connector

Config

Config files will be published to ~/ServerConnector/config/

Note: if config files are not automatically published run the config:publish command.

$ server-connector config:publish

defaults.php

Defines the default connection type if omitted.

// defaults.php

return [
	'type' => 'ssh',
];

connections.php

This is where you define all your server connections.

By default:

// 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.

Usage

Once you have defined some connections you can run

$ server-connector connect ConnectionNameOrAlias

Which will connect to the connection with the default connection type

Alternatively

$ server-connector connect sftp ConnectionNameOrAlias

To connect via SFTP if it isn't the default.

Register BASH Function

To add a function to your ~/.profile to call server-connector you can use

$ server-connector register

By default it will register a function connect() in your ~/.profile you can specify the function name by

$ server-connector register FunctionName

After running this command you will need to source your ~/.profile or restart your terminal application.

With the BASH function you can call this application by

connect ConnectionNameOrAlias