我想要记录 SFTP 文件传输。我的sshd_conf
是:
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
PermitRootLogin yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication yes
UsePAM yes
AllowTcpForwarding no
X11Forwarding no
UseDNS no
Subsystem sftp /usr/libexec/openssh/sftp-server -l INFO -f AUTH
主机密钥生成如下:
$ ssh-keygen -N "" -t rsa -f ssh_host_rsa_key
$ ssh-keygen -N "" -t ed25519 -f ssh_host_ed25519_key
SFTP 服务器在由此 Dockerfile 创建的 Docker 容器中运行:
FROM centos:7
RUN yum install -y openssh-server
RUN echo 'root:123456' | chpasswd
COPY ssh_host_rsa_key /etc/ssh/ssh_host_rsa_key
COPY ssh_host_ed25519_key /etc/ssh/ssh_host_ed25519_key
COPY sshd_config /etc/ssh/sshd_config
RUN chmod 400 /etc/ssh/*
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D", "-e"]
成功登录和文件上传后我唯一的输出是:
$ docker run --rm --name sftp-server -p "2222:22" test/sftp
Server listening on 0.0.0.0 port 22.
Server listening on :: port 22.
Accepted keyboard-interactive/pam for root from 172.17.0.1 port 58556 ssh2
不过,我期望输出如下所述OpenSSH 维基:
Oct 22 11:59:50 server internal-sftp[4929]: open "/home/fred/foo" flags WRITE,CREATE,TRUNCATE mode 0664
Oct 22 11:59:50 server internal-sftp[4929]: close "/home/fred/foo" bytes read 0 written 928
我的设置可能存在什么问题?
答案1
您已配置sftp-server
为记录到 syslog,而不是 stderr。您需要删除-l
/-f
选项并将其替换为-e
。