「OpenSSH」- 配置与管理

  CREATED BY JENKINSBOT

问题描述

该笔记将记录:在 Linux 中,SSH 配置与管理,以及常见问题的处理方案。

解决方案

Restrict SFTP user to multiple folders

Server

允许 ROOT 登录

How to enable or disable password authentication in SSH

# vim /etc/ssh/sshd_config
...
PermitRootLogin yes
...
PasswordAuthentication yes
...

# systemctl restart sshd.service

Client

在命令行中使用SSH密码

Send the password through stdin in `ssh-copy-id`

sshpass -p "$TMP_PASS" ssh-copy-id

客户端强制使用密码登录

How to force ssh client to use only password auth? – Unix & Linux Stack Exchange

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no example.com

如果用户名包含特殊字符

How to connect to SSH with ‘@’ character in username

比如包含 @ 符号:

ssh k4nz@example.com@example.com