Differences between revisions 3 and 9 (spanning 6 versions)
Revision 3 as of 2020-01-22 03:24:32
Size: 1419
Comment:
Revision 9 as of 2022-09-09 18:23:13
Size: 2036
Comment:
Deletions are marked like this. Additions are marked like this.
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'''. '''Secure Shell''' ('''SSH''') is a protocol that enables remote access to a server. This is primarily a Linux and BSD feature, with Windows systems preferring access by [[RemoteDesktopProtocol|RDP]]. The most common implementation is the '''OpenSSH''' project.

The server-side service is `sshd(8)`, while there are various client-side programs such as `ssh(1)` or PuTTY.

<<TableOfContents>>
Line 9: Line 13:
== Setup == == Installation ==
Line 11: Line 15:
On Linux, `sshd` runs by default. On BSDs, you will need to enable it. In `/etc/rc.conf`:

=== Client ===

If necessary, install `openssh`. Most Linux and BSD distributions will include it by default.

On Windows, try PuTTY and hope it works.



=== Server ===

Many Linux distributions have `openssh` installed and `sshd(8)` running by default. This is especially true of ISOs meant for server boxes.

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

For `init`-based systems, try `service sshd enable` or setting the following in `/etc/rc.conf`:
Line 21: Line 41:
== Require Authentication by Key == == Configuration ==
Line 23: Line 43:
To require that all logins use keys, use:

=== Require Authentication by Key ===

To require that all client logins use keys, use:
Line 34: Line 58:
Match user git Match User git
Line 42: Line 66:
Match address 192.168.*.*
  PAsswordAuthentication yes
Match Address 192.168.*.*
  PasswordAuthentication yes
Line 47: Line 71:
----
Line 50: Line 73:
=== Login Messages ===
Line 51: Line 75:
== 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 77:
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 83:
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.

SSH

Secure Shell (SSH) is a protocol that enables remote access to a server. This is primarily a Linux and BSD feature, with Windows systems preferring access by RDP. The most common implementation is the OpenSSH project.

The server-side service is sshd(8), while there are various client-side programs such as ssh(1) or PuTTY.


Installation

Client

If necessary, install openssh. Most Linux and BSD distributions will include it by default.

On Windows, try PuTTY and hope it works.

Server

Many Linux distributions have openssh installed and sshd(8) running by default. This is especially true of ISOs meant for server boxes.

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

For init-based systems, try service sshd enable or setting the following in /etc/rc.conf:

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)