Linux command
sshd 命令
网络
需要网络或远程资源。
常用示例
Start SSH daemon
sshd
Test configuration
sshd -t
Run in foreground
sshd -D
Use alternate config
sshd -f [/etc/ssh/sshd_config]
Debug mode
sshd -d
Extended debug
sshd -ddd
Specify listen port
sshd -p [2222]
Extended test mode
sshd -T -C user=[testuser],host=[example.com]
说明
sshd is the OpenSSH server daemon that listens for incoming SSH connections, authenticates users, and provides encrypted remote shell access, file transfer, and port forwarding services. It is the server-side counterpart to the ssh client. The daemon supports multiple authentication methods including public key, password, keyboard-interactive, and GSSAPI/Kerberos. Access can be restricted by user, group, and source address through configuration directives. Features like X11 forwarding, agent forwarding, and TCP port forwarding are individually controllable. Debug mode (-d) runs a single connection in the foreground with verbose output for troubleshooting, while -t validates the configuration file for syntax errors before restarting the service. Foreground mode (-D) is commonly used in container environments where the daemon should not detach from the controlling process.
参数
- -D
- Run in foreground, do not daemonize
- -d
- Debug mode; process one connection with verbose output. Multiple -d increases verbosity (max 3).
- -t
- Test mode; validate configuration file syntax
- -T
- Extended test mode; output effective configuration to stdout
- -C _connection_spec_
- Specify connection parameters for -T match testing (user, host, addr, laddr, lport, rdomain)
- -f _file_
- Specify configuration file (default: /etc/ssh/sshd_config)
- -h _host_key_file_
- Specify host key file (can be given multiple times for different key types)
- -g _login_grace_time_
- Grace time for client authentication (default: 120 seconds)
- -p _port_
- Listen port (can be given multiple times)
- -o _option_
- Specify configuration options in key=value format
- -E _log_file_
- Append debug logs to log_file instead of system log
- -e
- Write debug logs to stderr instead of system log
- -q
- Quiet mode; suppress non-fatal log messages
- -4
- Force IPv4 addresses only
- -6
- Force IPv6 addresses only
FAQ
What is the sshd command used for?
sshd is the OpenSSH server daemon that listens for incoming SSH connections, authenticates users, and provides encrypted remote shell access, file transfer, and port forwarding services. It is the server-side counterpart to the ssh client. The daemon supports multiple authentication methods including public key, password, keyboard-interactive, and GSSAPI/Kerberos. Access can be restricted by user, group, and source address through configuration directives. Features like X11 forwarding, agent forwarding, and TCP port forwarding are individually controllable. Debug mode (-d) runs a single connection in the foreground with verbose output for troubleshooting, while -t validates the configuration file for syntax errors before restarting the service. Foreground mode (-D) is commonly used in container environments where the daemon should not detach from the controlling process.
How do I run a basic sshd example?
Run `sshd` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -D do in sshd?
Run in foreground, do not daemonize