Linux Programming and Cloud Computing

Remote Access, Mounted Storage and the vi Editor

PGCP-BDA

SSH

Secure Shell authenticates a remote host and user, establishes an encrypted channel and carries terminal sessions, commands.

host key

An SSH host key identifies the server

public-key authentication

Public-key authentication proves possession of a private key by signing challenge data while the server checks the corresponding authorized public key.

SFTP

SFTP is the SSH file-transfer subsystem, carrying directory and file operations inside an authenticated encrypted SSH channel rather than using FTP.

mount point

A mount point is the directory at which a filesystem's root is attached to the single Linux directory tree.

fstab

/etc/fstab describes filesystems, mount points, types, options and boot-time checking policy

unmount

Unmount detaches a mounted filesystem after active references are released and buffered writes are flushed

vi modes

vi uses normal mode for commands, insert mode for entering text, visual mode for selecting text and command-line mode for file.

vi operators and motions

In vi, an operator such as delete, change or yank combines with a motion or text object, allowing commands such as dw and ci" to express action plus range.

vi search and substitution

vi uses /pattern or ?pattern for search and the :s command for scoped regular-expression replacement.

SSH and Mounted Storage

SSH provides encrypted remote login, command execution and file transfer. The client first verifies the server host key. Password authentication proves knowledge of a secret while public-key authentication proves possession of a private key. The public key belongs in authorized_keys; the private key remains protected on the client. scp copies files while sftp supplies an interactive transfer interface. Port forwarding carries another TCP connection through the encrypted session.

A block device becomes accessible after a filesystem is mounted on a directory. lsblk displays devices while blkid reports filesystem identifiers. mount attaches a filesystem for the session. /etc/fstab describes persistent mounts with a device, mount point, filesystem type, options and check fields. UUIDs are more stable than names such as /dev/sdb1. NFS and SMB mounts also depend on network and server availability. A filesystem cannot be cleanly unmounted while a process uses a file or working directory below its mount point.

Editing with vi

vi is modal. Normal mode interprets keys as commands. Insert mode enters text. Command-line mode accepts commands beginning with :. i, a and o enter insert mode in different positions; Escape returns to normal mode. Movement includes h, j, k, l, w, b, 0 and $. Operators combine with motions: dw deletes a word and d$ deletes to the line end. u undoes while p pastes.

:w writes, :q quits, :wq writes and quits and :q! abandons changes. /pattern searches forward and n repeats the search. :%s/old/new/g performs substitution throughout a file. Recognizing the active mode prevents commands from being inserted as text.

Ownership, Permissions and Remote Files

SSH configuration has system-wide and per-user layers. A user configuration can define aliases, names, ports, keys and jump hosts. An SSH agent keeps decrypted private keys in memory for a session. Agent forwarding should be limited because a compromised remote host can request signatures from the forwarded agent.

File ownership and mode bits still apply to mounted files. Network filesystems also translate identities between client and server. A numeric user ID mismatch can show unexpected ownership even when user names look similar. Mount options such as read-only, noexec, nosuid and nodev restrict selected behavior but do not replace correct file permissions. Before modifying /etc/fstab, mount -a can test entries without waiting for the next boot.

In vi a count repeats a command, so 3dd deletes three lines and 5j moves down five lines. yy copies a line and p places it after the current line. :set number displays line numbers. :e file edits another file and :r file reads another file below the current line. The editor may create a swap file for recovery after a crash; a warning about an existing swap file should be investigated before editing the same file concurrently.

Continue learning

Related notes

Put this topic into timed practice

Open mock tests when you want full-exam pacing, or keep drilling in practice mode.