SSH Between Unix-like Systems - Wed, Jun 12, 2024
Quick SSH setup between two Unix-like systems.
Preface
In this tutorial we are a client setting up an SSH connection to a hypothetical Linux server kokos.cy
.
Server Setup
On the server, install the
openssh-server
package. This package provides the server-side of the SSH protocol.sudo apt install openssh-server
Start the SSH service.
sudo systemctl start ssh
To enable the service to start on boot, run:
sudo systemctl enable ssh
Create user accounts on the server.
sudo adduser nicolas
Set a password for the user.
sudo passwd nicolas Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
Client Setup
Ensure that SSH is installed on the client.
Generate a digital signature if you do not have one.
ssh-keygen -t ed25519 -C "[email protected]"
Note: If you are using a legacy system that does not support the Ed25519 algorithm, you can use RSA:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Then create an alias for the server. Create the file
~/.ssh/config
and add:Host kokos HostName kokos.cy user nicolas
Copy the public key to the server. For this you can use SCP, or manually copy over the key.
scp ~/.ssh/id_ed25519.pub kokos:~/.ssh/authorized_keys
You can now login by typing
ssh kokos
without typing in a password.