Secure Server login via SSH

First login

ssh root@123.45.56.78 The authenticity of host '123.45.56.78 (123.45.56.78)' can't be established. 
ECDSA key fingerprint is SHA256:mX1fCAc5cyf2bG7BZnBPhrrmIKANdBtWzk676MgqhSs.
Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '123.45.56.78' (ECDSA) to the list of known hosts. root@123.45.56.78's password: You are required to change your password immediately (root enforced)
Changing password for root. 
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:

Creating a sudo user

$ su lukas 
$ sudo -v [sudo] password for lukas: Sorry, user lukas may not run sudo on veare.localdomain.

Allow access via SSH

$ ls ~/.ssh/ authorized_keys config id_rsa id_rsa.pub known_hosts

Creating a new key pair

$ ssh-keygen -t rsa Generating public/private rsa key pair. 
Enter file in which to save the key (/Users/YOURUSERNAME/.ssh/id_rsa): /Users/YOURUSERNAME/.ssh/devserver_rsa
Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/YOURUSERNAME/.ssh/devserver_rsa. Your public key has been saved in /Users/YOURUSERNAME/.ssh/devserver_rsa. The key fingerprint is: …

Transferring the key pair

$ cat ~/.ssh/id_rsa.pub | ssh root@123.45.56.78 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys" 
$ cat ~/.ssh/id_rsa.pub | ssh lukas@123.45.56.78 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Verifying the SSH login via ssh-key

$ ssh root@123.45.56.78 
$ exit
$ ssh lukas@123.45.56.78
$ exit

Disabling Root-Login and login via password

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store