Based on the Linux Master 2 exam syllabusReport an error
scp and sftp.| Service | Port | Encryption |
|---|---|---|
| TELNET | 23 | None — plain text |
| SSH | 22 | Yes |
| rlogin / rsh | 513 / 514 | None (the old r-family) |
telnet server 80.$ telnet 192.168.0.10 80
Trying 192.168.0.10...
Connected to 192.168.0.10.
Escape character is '^]'.Connected appears, that port is open. If it is closed, you get Connection refused. TELNET simply opens a TCP connection to the other side's port and exchanges characters as they are, which is why it works for this kind of check.Ctrl+] as the message says, then type quit.ssh user@192.168.0.10 # connect
ssh -p 2222 user@server # specify a port
ssh -X user@server # remote GUI (X11 forwarding)| Feature | Description |
|---|---|
| Encryption | Login information, commands, and results are all encrypted |
| Public-key authentication | You can authenticate with a key pair instead of a password |
| Tunneling | Other traffic can be passed through SSH |
| Implementation | OpenSSH (daemon sshd) |
ssh-keygen # generate a key pair (~/.ssh/id_rsa, id_rsa.pub)
ssh-copy-id user@server # register the public key on the server~/.ssh/authorized_keys.600.$ ssh alice@192.168.0.10
The authenticity of host '192.168.0.10 (192.168.0.10)' can't be established.
ED25519 key fingerprint is SHA256:(fingerprint string of the server key).
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.0.10' (ED25519) to the list of known hosts.
alice@192.168.0.10's password:yes, that server's key is recorded in ~/.ssh/known_hosts on your computer, and you are not asked again.user@, SSH tries to connect with the name you are currently logged in as. You can also give the name with -l, as in ssh -l alice 192.168.0.10.| File | Location | What it holds |
|---|---|---|
~/.ssh/id_rsa | Connecting side | Your private key — never leaves your machine |
~/.ssh/id_rsa.pub | Connecting side | Your public key — what you hand to the server |
~/.ssh/authorized_keys | Receiving side (server) | A list of public keys allowed to log in to this account |
~/.ssh/known_hosts | Connecting side | The keys of the servers you have connected to |
/etc/ssh/sshd_config | Server | Configuration of the SSH server (daemon) |
/etc/ssh/ssh_config | Connecting side | Configuration of the SSH client |
authorized_keys is "users allowed in," and known_hosts is "servers I know." Questions swap these two files, which point in opposite directions.sshd_config and ssh_config differ by a single letter, d. The d stands for daemon, so sshd_config is the server side. Settings such as changing the connection port from 22 to another number or blocking direct root login live there.id_rsa, and for ED25519 it is id_ed25519. Which type is made by default depends on the OpenSSH version. The rule that the file with .pub is the public key stays the same.TELNET and SSH are "remote access," not "file transfer." This is why TELNET is the answer to "Which is least related to a service for exchanging files?"
| Port | Purpose |
|---|---|
| 21 | Control — commands are exchanged |
| 20 | Data — the actual files travel |
Active Passive
Client ──21──► Server Client ──21──► Server
Client ◄─20─── Server Client ────► Server
(server opens the (client opens the
connection) connection)| Aspect | Active mode | Passive mode |
|---|---|---|
| Data connection | Server to client | Client to server |
| Server port | Port 20 | A random high port |
| Firewall | Easily blocked by the client's firewall | Passes through well |
anonymous, and by convention you enter your email address as the password.anonymous itself.| Command | What it does |
|---|---|
get | Download one file |
put | Upload one file |
mget / mput | Download / upload several files |
ls, cd, pwd | Navigate the remote side |
lcd | Change the local directory |
bin / ascii | Binary / text transfer mode |
bye, quit | Exit |
Images and compressed files must be transferred in
bin(binary) mode. If you transfer them in ascii mode, line endings get converted and the file is corrupted.
$ ftp 192.168.0.10
Connected to 192.168.0.10.
220 (vsFTPd 3.0.3)
Name (192.168.0.10:alice): anonymous
331 Please specify the password.
Password:
230 Login successful.
ftp> bin
200 Switching to Binary mode.
ftp> get backup.tar.gz
… (transfer progress output omitted)
226 Transfer complete.
ftp> bye
221 Goodbye.ftp> prompt is showing, you are inside the FTP program, not the shell. The ls and cd you type here act on the server-side directory. To change directories on your own computer, use lcd.get is server to you (download), and put is you to server (upload).| Command | What it does |
|---|---|
prompt | Turns on or off the per-file confirmation during mget and mput |
hash | Shows transfer progress with # |
passive | Turns passive mode on or off |
delete / mkdir | Delete a file on the server / create a directory |
!command | Run a shell command on your own computer without leaving FTP |
mget *.txt, use the commands that start with m. get *.txt does not work as intended.| Method | Based on | Feature |
|---|---|---|
scp | SSH | Copy with a single command line |
sftp | SSH | Used interactively, like FTP |
| FTPS | FTP + SSL | FTP with encryption added |
rsync | SSH, etc. | Transfers only the changed parts — good for backups |
scp file.txt user@server:/home/user/ # send
scp user@server:/home/user/file.txt . # receive
scp -r folder user@server:/home/user/ # a whole directory
sftp user@server # interactive
sftpandFTPSare different. sftp is based on SSH, and FTPS is FTP wrapped in SSL. Their names are similar, so questions swap them.
scp has the same order as cp — scp source destination. The remote side is written as user@host:path, and the colon (:) marks it as remote.scp file.txt alice@server just copies the file into a new file named alice@server in the current directory and finishes.ssh uses lowercase -p 2222, while scp and sftp use uppercase -P 2222. The lowercase -p of scp is a different option that preserves modification times and permissions.scp and sftp do everything over the single SSH port 22. Unlike FTP, which uses two ports, opening only port 22 on the firewall allows both connecting and file transfer.rsync is used in the form rsync -av source destination. -a preserves permissions, times, and so on as they are, -v shows progress, and -z compresses during transfer. From the second run on it sends only what changed, so it is fast.| Old tool (plain text) | Replacement (SSH-based) |
|---|---|
telnet · rlogin | ssh |
rsh (run a single command remotely) | ssh host command |
rcp | scp |
ftp | sftp |
rlogin, rsh, rcp) let people in without a password based only on a "trusted hosts" list, so they were weak on security. SSH replaced all three.| Service | Port | Encryption | What it does |
|---|---|---|---|
| TELNET | 23 | None | Remote access |
| SSH | 22 | Yes | Remote access (+ the basis of file transfer) |
| FTP | 21 control / 20 data | None | File transfer |
| TFTP | 69 (UDP) | None | Simple file transfer, no authentication |
| SFTP · SCP | 22 | Yes | File transfer |
| rlogin / rsh | 513 / 514 | None | Remote access / remote command |
| Symptom | Cause | Fix |
|---|---|---|
Connection refused | No daemon is waiting on that port | Check that sshd is running on the server and the port number is right |
Hangs for a long time, then Connection timed out | Blocked along the way or the address is wrong | Check the path with the firewall and ping |
Permission denied (publickey) | My public key is not in the server's authorized_keys | Register it with ssh-copy-id |
| The key is ignored even though a private key exists | The private key file's permissions are too open | chmod 600 ~/.ssh/id_rsa |
REMOTE HOST IDENTIFICATION HAS CHANGED | It differs from the server key recorded in known_hosts | Confirm the server was really replaced, then delete the old line |
FTP login works but it hangs at ls | The active-mode data connection is blocked by a firewall | Switch to passive mode with passive |
| Method | Description |
|---|---|
| VNC | Transmits the screen itself. Platform independent |
| XRDP | Connects using Windows Remote Desktop (RDP) |
ssh -X | X11 forwarding — brings up individual windows |
Tomorrow we cover NFS and Samba, where multiple computers share files.
anonymous account.scp / sftp : Tools that copy or transfer files over SSH.rsync : A tool that synchronizes efficiently by transferring only the changed parts.Click a choice to reveal the answer and explanation.
Question 1
Which of the following is a characteristic of SSH compared with TELNET?
Question 2
Which of the following is a command that copies files to and from a remote system over SSH?
Question 3
Which of the following is the port number FTP uses for the control connection that exchanges commands?
Question 4
Which of the following is the account name used to connect to anonymous FTP?
Question 5
Which of the following is the least related to a service for exchanging files?