Skip to content

Commit

Permalink
Merge pull request #42 from phredmund/main
Browse files Browse the repository at this point in the history
initial commit for SSH page
  • Loading branch information
nothingneko authored Jun 26, 2024
2 parents 5b307d6 + 9fae3b4 commit 67388cf
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
Binary file added public/assets/ssh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const SIDEBAR: Sidebar = {
{ text: "Permissions", link: "en/linux/permissions" },
{ text: "Software and Package Management", link: "en/linux/software" },
{ text: "The Shell", link: "en/linux/shell" },
{ text: "SSH", link: "en/linux/ssh"}
{ text: "Security and Privacy", link: "en/linux/securityprivacy" },
],

Expand Down
104 changes: 104 additions & 0 deletions src/content/docs/en/linux/ssh.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
title: SSH Secure Shell
description: "An overview of the SSH utility."
---

import Alert from "../../../../components/Docs/Alert.astro";

Secure Shell ("SSH") is one of the most common utilities when access to a remote device is needed. It's encrypted, powerful, and simple to understand.

## SSH overview
SSH uses a client/server model where one computer acts as an SSH server[^1] and allows other computers to connect.

![Example SSH Client and Server](/assets/ssh.png)

## Connecting to an SSH Server
To access a device remotely, the `ssh` command is run from [the shell](/en/linux/shell), mostly used with this format:

```zsh
ssh [username@]<server url>
```
If you don't specify a username then SSH will attempt to connect you using the username with which you are logged in. Here are some examples:
- `ssh [email protected]`
- This will attempt to connect to the server at myserver.com using the username myuser
- `ssh [email protected]`
- This is just like the example above except you can also specify an IP address instead of a hostname
- `ssh myserver.com`
- This will attempt to connect to the SSH server at myserver.com using your current username

When using any of the above commands, once connected to the remote server you'll be prompted for a password.

## Running Your Own SSH Server
Most modern Linux distros come with the required software to host your own SSH server. To allow users to connect to your machine, start the SSH server application using
```zsh
sudo systemctl start sshd
```
Note that the above command uses `sudo`. The `sudo` command will execute the following commands as root (the superuser). For many commands that involve starting and stopping servers, the permission of the system's superuser is necessary. You can read more about the `sudo` command [here](en/linux/permissions). The above command also uses the `systemctl` command. This command is mostly used to manage servers or other Linux services.

Once the above command is run, your machine will begin listening for incoming connections on port 22. You can verify that the SSH server application started correctly by using the command
```zsh
systemctl status sshd
```

You should see output similar to this:

```zsh
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; preset: enabled)
Drop-In: /usr/lib/systemd/system/service.d
└─10-timeout-abort.conf
Active: active (running) since Sun 2024-04-07 14:00:20 EDT; 44min ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 1065 (sshd)
Tasks: 1 (limit: 4396)
Memory: 156.0K
CPU: 50ms
CGroup: /system.slice/sshd.service
└─1065 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Apr 07 14:00:20 ultramarine systemd[1]: Starting sshd.service - OpenSSH server daemon...
Apr 07 14:00:20 ultramarine sshd[1065]: Server listening on 0.0.0.0 port 22.
Apr 07 14:00:20 ultramarine sshd[1065]: Server listening on :: port 22.
Apr 07 14:00:20 ultramarine systemd[1]: Started sshd.service - OpenSSH server daemon.
```

Check for the field that says `Active: active (running)` to ensure that the SSH server is listening for incoming connections.

If you'd like to stop the SSH server, you can do so with
```zsh
sudo systemctl stop sshd
```

You should see output similar to this:
```zsh

○ sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; preset: enabled)
Drop-In: /usr/lib/systemd/system/service.d
└─10-timeout-abort.conf
Active: inactive (dead) since Sun 2024-04-07 14:50:24 EDT; 3s ago
Duration: 50min 4.206s
Docs: man:sshd(8)
man:sshd_config(5)
Process: 1065 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 1065 (code=exited, status=0/SUCCESS)
CPU: 58ms

Apr 07 14:50:24 ultramarine systemd[1]: Stopping sshd.service - OpenSSH server daemon...
Apr 07 14:50:24 ultramarine sshd[1065]: Received signal 15; terminating.
Apr 07 14:50:24 ultramarine systemd[1]: sshd.service: Deactivated successfully.
Apr 07 14:50:24 ultramarine systemd[1]: Stopped sshd.service - OpenSSH server daemon.
```

#### [← Back To: Software and Package Management](/en/linux/software)

[^1]### A Note about the Word "Server"
It's common to hear the word "server" used but not understand exactly what is meant. Here are a couple examples of how "server" can be used:

- It can refer to a physical machine somewhere
- Ex: Our email server lost power over the weekend.
- It can refer to a specific *application* running on one machine (or even a number of machines across the world!)
- Ex: The SSH server is up so that users can connect.

In this guide we'll try to make it clear to which we're referring.

0 comments on commit 67388cf

Please sign in to comment.