Linux Tutorials & Things ssh

Generate SSH Key file and Configure OpenSSH

STEP 1:

Tip: Replace USERNAME with your systems user name.

Generate an Ed25519 key, and save the file as USERNAME_ssh;

ssh-keygen -t ed25519

ssh keygeneration example

Alternative - Generate a 8192bit rsa key;

ssh-keygen -t rsa -b 8192

STEP 2:

USERNAME_ssh= private key ( keep it secret, keep it safe )

USERNAME_ssh.pub= public key ( is seen by all )

Make a hidden directory in user home folder;

mkdir /home/USERNAME/.ssh

Move Public key file into the .ssh directory and name it as authorized_keys;

mv USERNAME_ssh.pub /home/USERNAME/.ssh/authorized_keys

Copy private key from current location to the users home folder ready for download;

cp USERNAME_ssh /home/USERNAME

Set owner permissions for the private key file;

chown USERNAME:USERNAME /home/USERNAME/USERNAME_ssh

Download private key file to your local machine;

SFTP COPY (run on local Linux Machine)

Copy private key to local machine;

sftp USERNAME@DOMAIN

get USERNAME_ssh

sftp login and get keyfile example

Note - Delete the private key file from the server after download;


SSH SERVER CONFIG:

We will disable root SSH logins, disable password only SSH access and define an alternative port number. Please change the port number to a random number between 20000 - 50000;

sudo nano /etc/ssh/sshd_config
  • Port XXXX
  • Protocol 2
  • RSAAuthentication yes
  • PubkeyAuthentication yes
  • PasswordAuthentication no
  • PermitRootLogin no
  • AllowUsers USERNAME
  • X11Forwarding no
  • PrintMotd yes
  • UsePAM no

These setting will not take effect until the sshd service is restarted

TEST SSH LOGON (run on local Linux Machine)

SSH Successful Login example

ssh -i PATHTOKEY USERNAME@DOMAIN -p PORTNUMBER

If logon is succesfull run;

service sshd restart

How to install Fish Shell and oh-my-fish

What is Fish ?

Fish is a fully-equipped command line shell (like bash or zsh) that is smart and user-friendly. fish supports powerful features like syntax highlighting, auto-suggestions, and tab completions that just work, with nothing to learn or configure. 1

STEP1

Install Fish from the Opensuse Debian Repo;
Check your OS version - the following commands are for Debian 8.x Jessie;

echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/2/Debian_8.0/ /' >> /etc/apt/sources.list.d/fish.list 
apt-get update
apt-get install fish

STEP2

Change the current shell session from Bash to Fish;

fish

Set the default shell for the current user to Fish;

chsh -s /usr/bin/fish

OH-MY-FISH:

Run the following commands to Install oh-my-fish:

curl -L https://github.com/oh-my-fish/oh-my-fish/raw/master/bin/install > install

fish install

omf update

Install theme lolfish

omf install lolfish

For more information on oh-my-fish themes and other packages check out their github page

Fish shell with oh-my-fish