如何使用atmoz/sftp?
How to use atmoz/sftp?
https://github.com/atmoz/sftp
我正在尝试将其设置为进行测试,但我尝试按照 README 进行操作,但没有成功。我需要使用 ssh 密钥登录,但指示却一直要求我输入密码。生成密钥时我没有设置密码。
/home/test/sftp_testing
$ ls
test1.txt test2.txt test3.txt testing4.txt
$ ssh-keygen -t ed25519 -f ssh_host_ed25519_key < /dev/null
$ ssh-keygen -t rsa -b 4096 -f ssh_host_rsa_key < /dev/null
$ ls
ssh_host_ed25519_key ssh_host_ed25519_key.pub ssh_host_rsa_key ssh_host_rsa_key.pub test1.txt test2.txt test3.txt testing4.txt
$ docker run \
> -v /home/test/sftp_testing/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key \
> -v /home/test/sftp_testing/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key \
> -v /home/test/sftp_testing/share:/home/foo/share \
> -p 9000:22 -d atmoz/sftp \
> foo::1001
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7e10e9d5a864 atmoz/sftp "/entrypoint foo::10…" 4 seconds ago Up 3 seconds 0.0.0.0:9000->22/tcp, :::9000->22/tcp priceless_edison
$ sftp -P 9000 -i /home/test/sftp_testing/ssh_host_rsa_key -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null foo@10.0.2.15
Warning: Permanently added '[10.0.2.15]:9000' (ED25519) to the list of known hosts.
foo@10.0.2.15`'s password:
因此,如果您想尝试使用密钥,说明似乎并不完整。我能够让它与以下内容一起工作:
docker run \
-v /home/test/sftp_testing/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key \
-v /home/test/sftp_testing/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key \
-v /home/test/sftp_testing/ssh_host_ed25519_key.pub:/home/foo/.ssh/keys/ssh_host_ed25519_key.pub:ro \
-v /home/test/sftp_testing/ssh_host_rsa_key.pub:/home/foo/.ssh/keys/ssh_host_rsa_key.pub:ro \
-v /home/test/sftp_testing/share:/home/foo/share \
-p 9000:22 -d test_thing \
foo::1001
sftp -P 9000 -i /home/testing/sftp_testing/ssh_host_ed25519_key -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null foo@10.0.2.15
https://github.com/atmoz/sftp 我正在尝试将其设置为进行测试,但我尝试按照 README 进行操作,但没有成功。我需要使用 ssh 密钥登录,但指示却一直要求我输入密码。生成密钥时我没有设置密码。
/home/test/sftp_testing
$ ls
test1.txt test2.txt test3.txt testing4.txt
$ ssh-keygen -t ed25519 -f ssh_host_ed25519_key < /dev/null
$ ssh-keygen -t rsa -b 4096 -f ssh_host_rsa_key < /dev/null
$ ls
ssh_host_ed25519_key ssh_host_ed25519_key.pub ssh_host_rsa_key ssh_host_rsa_key.pub test1.txt test2.txt test3.txt testing4.txt
$ docker run \
> -v /home/test/sftp_testing/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key \
> -v /home/test/sftp_testing/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key \
> -v /home/test/sftp_testing/share:/home/foo/share \
> -p 9000:22 -d atmoz/sftp \
> foo::1001
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7e10e9d5a864 atmoz/sftp "/entrypoint foo::10…" 4 seconds ago Up 3 seconds 0.0.0.0:9000->22/tcp, :::9000->22/tcp priceless_edison
$ sftp -P 9000 -i /home/test/sftp_testing/ssh_host_rsa_key -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null foo@10.0.2.15
Warning: Permanently added '[10.0.2.15]:9000' (ED25519) to the list of known hosts.
foo@10.0.2.15`'s password:
因此,如果您想尝试使用密钥,说明似乎并不完整。我能够让它与以下内容一起工作:
docker run \
-v /home/test/sftp_testing/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key \
-v /home/test/sftp_testing/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key \
-v /home/test/sftp_testing/ssh_host_ed25519_key.pub:/home/foo/.ssh/keys/ssh_host_ed25519_key.pub:ro \
-v /home/test/sftp_testing/ssh_host_rsa_key.pub:/home/foo/.ssh/keys/ssh_host_rsa_key.pub:ro \
-v /home/test/sftp_testing/share:/home/foo/share \
-p 9000:22 -d test_thing \
foo::1001
sftp -P 9000 -i /home/testing/sftp_testing/ssh_host_ed25519_key -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null foo@10.0.2.15