Secure Server login via SSH

First login

ssh root@ The authenticity of host ' (' can't be established. 
ECDSA key fingerprint is SHA256:mX1fCAc5cyf2bG7BZnBPhrrmIKANdBtWzk676MgqhSs.
Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '' (ECDSA) to the list of known hosts. root@'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 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/ | ssh root@ "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys" 
$ cat ~/.ssh/ | ssh lukas@ "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Verifying the SSH login via ssh-key

$ ssh root@ 
$ exit
$ ssh lukas@
$ 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