Differences between revisions 3 and 13 (spanning 10 versions)
Revision 3 as of 2020-01-22 03:24:32
Size: 1419
Comment:
Revision 13 as of 2023-01-09 01:48:17
Size: 1903
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= SSH = = OpenSSH =
Line 3: Line 3:
'''Secure Shell''' ('''SSH''') is a protocol that enables remote access to a server. It encompasses both the client-side application (`ssh`) and the server-side daemon (`sshd`). The most common implementation for Linux and BSD is '''OpenSSH'''. '''OpenSSH''' is a [[Protocols/SSH|SSH]] client and server.

OpenSSH is widely deployed on [[Linux]] and [[BSD]] operating systems, with Windows systems preferring access by [[Protocols/RDP|RDP]].

The service is `sshd(8)` and the utility is `ssh(1)`.

<<TableOfContents>>
Line 9: Line 15:
== Setup == == Installation ==
Line 11: Line 17:
On Linux, `sshd` runs by default. On BSDs, you will need to enable it. In `/etc/rc.conf`: Most Linux and BSD distributions will include it by default. Otherwise, it should be available through an `openssl` package.

Furthermore, many Linux distributions have `sshd(8)` running by default.

For `systemd(1)`-capable systems, [[Linux/Systemd|start and enable]] `sshd.service`.

For OpenRC-based systems, [[Linux/OpenRC|start and add]] the `sshd` service.

For BSDs, [[BSD/Init|start]] the `sshd` service. To have it automatically start on boot, try editing `/etc/rc.conf` like:
Line 21: Line 35:
== Require Authentication by Key == == Configuration ==
Line 23: Line 37:
To require that all logins use keys, use:

=== Require Authentication by Key ===

To require that all client logins use keys, use:
Line 34: Line 52:
Match user git Match User git
Line 42: Line 60:
Match address 192.168.*.*
  PAsswordAuthentication yes
Match Address 192.168.*.*
  PasswordAuthentication yes
Line 47: Line 65:
----
Line 50: Line 67:
=== Login Messages ===
Line 51: Line 69:
== Login Messages == Usually any messages printed on login are actually handled by PAM. This can be tricky to configure, so instead disable the default login messages and configure the shell profile to print the desired messages.
Line 53: Line 71:
Usually any messages printed on login are actually handled by PAM. This can be tricky to configure, so instead disable all login messages and recreate any desired messages.

To disable all PAM login messages for a user, just:
To disable all PAM login messages for a user, try:
Line 61: Line 77:
Default PAM configurations print `/etc/motd` and the output of `/usr/bin/lastlog --user USERNAME`. These can just as easily be added to `~/.bashrc`. Note that default PAM configurations print `/etc/motd` and the output of `/usr/bin/lastlog --user USERNAME` on login.

OpenSSH

OpenSSH is a SSH client and server.

OpenSSH is widely deployed on Linux and BSD operating systems, with Windows systems preferring access by RDP.

The service is sshd(8) and the utility is ssh(1).


Installation

Most Linux and BSD distributions will include it by default. Otherwise, it should be available through an openssl package.

Furthermore, many Linux distributions have sshd(8) running by default.

For systemd(1)-capable systems, start and enable sshd.service.

For OpenRC-based systems, start and add the sshd service.

For BSDs, start the sshd service. To have it automatically start on boot, try editing /etc/rc.conf like:

sshd_enable="YES"


Configuration

Require Authentication by Key

To require that all client logins use keys, use:

PubkeyAuthentication   yes
AuthorizedKeysFile     .ssh/authorized_keys
PasswordAuthentication no

To make an exception for a user, add at the bottom of the file:

Match User git
  PasswordAuthentication yes
Match all

To make an exception for the local network, add (also at the bottom of the file):

Match Address 192.168.*.*
  PasswordAuthentication yes
Match all

Login Messages

Usually any messages printed on login are actually handled by PAM. This can be tricky to configure, so instead disable the default login messages and configure the shell profile to print the desired messages.

To disable all PAM login messages for a user, try:

touch ~/.hushlogin

Note that default PAM configurations print /etc/motd and the output of /usr/bin/lastlog --user USERNAME on login.


CategoryRicottone

Encryption/OpenSSH (last edited 2023-04-06 16:23:08 by DominicRicottone)