[Linux] Learn Linux step by step - sshd command (177)

Posted by pushpendra.php on Fri, 23 Aug 2019 14:14:40 +0200

00. Catalogue

Articles Catalogue

01. Overview of commands

The sshd command is the server Daemon in the opensshd software suite.

Openssh suite establishes encrypted data communication between two trusted hosts in an insecure network, which is a substitute for rlogin, rsh and other communication tools for plaintext transmission of data. Sshd instruction is the core program of openssh suite, and other instructions (such as sftp-server, slogin, scp) are based on sshd command.

02. Command format

Format: sshd [parameter]

03. Common Options

- 4. Mandatory use of IPv4 addresses
 - 6. Mandatory use of IPv6 addresses
 - D. Running servers in a non-daemon manner
 - d. Debugging mode
 - e. Send errors to standard error devices rather than to system logs
 - f < Profile > Configuration file for specified server
 - g<logon expiration time> Specifies the expiration time of client login (default time is 120 seconds). If the user fails to authenticate correctly within this time limit, the server disconnects the client.
- H < host key file > Specifies to read host key file
 - i. sshd runs in inetd mode
 - O < Options > Specify configuration options for sshd
 - P < Port > Specifies the port number to be used
 - q. Quiet mode, no information is written to the system log
 - t. Test mode

04. Reference examples

4.1 Running sshd in debugging mode

[root@localhost ~]# /sbin/sshd -d
debug1: sshd version OpenSSH_7.4, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: private host key #0: ssh-rsa SHA256:ij2RmMAMbn1G/0EGj7GLv8i2qMDmu/JweqgwID/hUto
debug1: private host key #1: ecdsa-sha2-nistp256 SHA256:YheY5RH3PZ27UMYxdPwhraYfS4bCK/p3+xwdWL0O9WQ
debug1: private host key #2: ssh-ed25519 SHA256:QfMmdy6Gu06GtTXezckS8FS7QkxxgQxR2tfeXT28cuo
debug1: rexec_argv[0]='/sbin/sshd'
debug1: rexec_argv[1]='-d'
debug1: Set /proc/self/oom_score_adj from 0 to -1000
debug1: Bind to port 22 on 0.0.0.0.
Bind to port 22 on 0.0.0.0 failed: Address already in use.
debug1: Bind to port 22 on ::.
Bind to port 22 on :: failed: Address already in use.
Cannot bind any address.
[root@localhost ~]# 

4.2 Running sshd in test mode

[root@localhost ~]# /sbin/sshd -t
[root@localhost ~]# 

4.3 Mandatory use of IPv6 addresses

[root@localhost ~]# /sbin/sshd -6
[root@localhost ~]# 

4.4 Mandatory use of IPv4 addresses

[root@localhost ~]# /sbin/sshd -4
[root@localhost ~]# 

4.5 View sshd service status

[root@localhost ~]# systemctl status sshd
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since 3 2019-08-21 15:17:18 CST; 2 days ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 772 (sshd)
    Tasks: 1
   CGroup: /system.slice/sshd.service
           └─772 /usr/sbin/sshd -D

4.6 Start sshd service

[root@localhost ~]# systemctl start sshd
[root@localhost ~]# 

05. Appendix

Reference resources: [Linux] A step-by-step summary of the series of Linux tutorials

Topics: openssh ssh Linux network