Skip to content

Latest commit

 

History

History
136 lines (83 loc) · 4.36 KB

File metadata and controls

136 lines (83 loc) · 4.36 KB

SSH

Table of contents

What is SSH

SSH (Secure Shell) is a protocol used to securely connect to remote machines.

You can use it to connect to your virtual machine.

Important

Windows users: Use WSL (Windows Subsystem for Linux). Do not use PowerShell, cmd.exe, or Git Bash — the commands below are not guaranteed to work there.

SSH login methods

Login using a password

Password-based authentication asks you to type the password of the user.

Login using an SSH key

Key-based authentication uses your SSH private key to prove your identity.

The remote host checks whether the matching SSH public key is listed as authorized.

This is the recommended method.

See Set up the SSH access to the VM as the user <user>.

SSH key pair

SSH uses a key pair for authentication:

SSH public key

An SSH public key is the shareable half of an SSH key pair.

You give your public key to remote hosts — they store it in ~/.ssh/authorized_keys to recognize you on future connections.

The public key file has a .pub extension (e.g., se_toolkit_key.pub).

SSH private key

An SSH private key is the secret half of an SSH key pair.

It stays on your local machine and is never shared. During authentication, SSH uses it to prove your identity without sending it over the network.

Caution

Never share your private key. Anyone who has it can authenticate as you.

sshd

sshd (the SSH daemon) is a program that runs on the remote host and listens for incoming SSH connections.

You do not need to configure it — your VM already has it running.

ssh-agent

ssh-agent is a background program that stores your private SSH key in memory for the duration of your session.

When ssh-agent holds your key, you do not need to type a passphrase every time you connect.

SSH shell

An SSH shell is the interactive shell session you get after connecting to the VM over SSH.

Commands you run in it execute on the remote machine, not on your local computer.

SSH shell prompt

A typical SSH shell prompt looks like:

<user>@<host>:<directory-path>$

See:

Note

The $ at the end indicates a regular user. A # indicates the user root.

Check whether you run an SSH shell

  1. To check whether you run an SSH shell,

    run in the VS Code Terminal:

    w
    
  2. Look at the FROM column.

    If the value in that column:

    • is an IP address, you run in an SSH shell.
    • -, you run on your local machine (computer).

scp

scp (Secure Copy) copies files between machines over SSH.

Common pattern:

scp -r <local-path> <user>@<host>:<remote-path>

The -r flag copies directories recursively.