/ssh-quick-config

Quickly and easily generates your SSH config file and handles ssh keys.

Primary LanguageShellMIT LicenseMIT

WARNING : CURRENTLY EXPERIMENTAL

ssh-quick-config

Quickly and easily generates your SSH config file and handles the copying and adding of your keys to hosts. Made to save time from entering many multiple commands!

Example Command

echo "MyServer===usr@192.168.0.10===Passxwrd" | sudo ./sshqc

Generated Config Block

# MyServer
# Generated by ssh-quick-config
Host MyServer
	User usr
	HostName 192.168.0.10
	IdentityFile /home/rob/.ssh/usr.key
	Port 22

Installation

Installation can be done in one of two ways.

The first is to simple use wget to download the latest version from GitHub.

*or sudo curl -O ... for OsX!

sudo wget https://raw.githubusercontent.com/robswc/ssh-quick-config/main/sshqc

or, to make things easier

sudo wget https://raw.githubusercontent.com/robswc/ssh-quick-config/main/sshqc;sudo mv sshqc /bin;sudo chmod +x /bin/sshqc

The above set of commands will download via wget, move the file into your /bin and set the necessary permissions. This allows you to call sshqc anywhere.

Dependencies

The sshqc script requires an additional piece of software.

sshpass

sshpass is a utility designed for running ssh using the mode referred to as "keyboard-interactive" password authentication, but in non-interactive mode.

ssh-keygen

Before running sshqc one must first have a ~/.ssh directory with a valid public key file.

Ubuntu

apt-get install sshpass

OS X

The following is an unofficial brew package (warning, may not be up-to-date!)

brew install hudochenkov/sshpass/sshpass

Usage

Basic

To use sshqc simply supply it, via | (pipe) with name===host===password; pairs. Where name is the of the server/host, host is the host (i.e. user@192.168.0.10) and password is the password for the host user.

**Important: On OSX

echo "MyServer===rob@192.168.0.10===MySecretPass007!" | sudo -E ./sshqc

The above command will:

  • Log into your server, using the provided credentials.
  • Copy the server's public key, saving it to ~/.ssh/name.key.
  • Add the local user's public key to the server's authorized_keys file.
  • Generate a block of code in your ~/.ssh/config, allowing you to connect with ssh name

Advanced

cat servers.txt | sudo ./sshqc

The above command will do the same things as the basic, except it will instead be reading the server credentials from a text file. The format of the text file should be:

MyServer1===rob@192.168.0.11===MySecretPass007!;MyServer2===rob@192.168.0.12===MySecretPass007!

All the server pairs must be on one line, seperated by a ; - or else the script will not work.

Keep in mind, storing passwords in plaintext is generally a bad idea. It's recommended to delete any input file immediately after use!