【问题标题】:Connect SFTP Server by ssh key通过 ssh 密钥连接 SFTP 服务器
【发布时间】:2023-03-16 01:20:01
【问题描述】:

我想在 docker 容器内的本地机器上模拟 SFTP 服务器。

我找到了这张图片:https://github.com/atmoz/sftp

并根据镜像的github页面准备了这个docker-compose文件。

我的 docker-compose 文件如下所示;

version: "3"

services:
  sftp:
    image: atmoz/sftp
    ports:
      - "2222:22"
    command: foo:pass:1001
    volumes:
      - /$HOME/ftp-server-storage:/home/foo/upload
      - ./../../src/main/resources/ssh-key/app_ssh_key.pub:/home/foo/.ssh/keys/id_rsa.pub:ro
    networks:
      - sam_network

networks:
  sam_network:
    driver: bridge

我已经用这个命令生成了 RSA 密钥对;

ssh-keygen -b 4096 -t rsa -f app_ssh_key

之后,我希望使用该命令连接服务器;

sftp -P 2222 -oIdentityFile=app_ssh_key foo@localhost

注意;我为这个参数传递了私钥文件; -oIdentityFile=app_ssh_key

但我收到此错误;

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
SHA256:EEzFNVY6jLOSg0gJyprSz6AZKlgar+gHZkreQnaNOeo.
Please contact your system administrator.
Add correct host key in /Users/sam/.ssh/known_hosts to get rid of this message.
Offending ED25519 key in /Users/sam/.ssh/known_hosts:2
ED25519 host key for [localhost]:2222 has changed and you have requested strict checking.
Host key verification failed.
Connection closed

我无法想象有什么问题?

【问题讨论】:

  • 请将您的问题移至Super User(在此处删除,在此处重新发布)。这是off-topic here
  • 顺便说一句,问题出在服务器的主机密钥上,而不是您的私钥/密钥对。

标签: docker ssh rsa sftp


【解决方案1】:

尝试删除文件/Users/sam/.ssh/known_hosts

或者像这样执行ssh:

ssh -o StrictHostKeyChecking=no foo@localhost

【讨论】:

    猜你喜欢
    • 2017-04-17
    • 1970-01-01
    • 2014-10-13
    • 2022-07-11
    • 2021-03-09
    • 2011-05-21
    • 2020-10-22
    • 2011-05-21
    • 1970-01-01
    相关资源
    最近更新 更多