当尝试在 Linux 中运行 libssh 服务器时,我遇到了错误侦听套接字:无法导入私有 RSA 主机密钥。我使用了两个例子作为参考。https://github.com/substack/libssh/blob/master/examples/samplesshd.c和https://github.com/PeteMo/sshpot/blob/master/main.c。但后一个参考文献在自述文件中提到使用公钥,而不是私钥,这让我感到困惑。
我仍然是一个新手 C 实践者,所以我非常确定我做错了一些事情。也许甚至 asm 本人(我相信是他的创造者)也会给我一两个快速提示。这是我的代码:
#include <libssh/libssh.h>
#include <libssh/server.h>
#include <libssh/callbacks.h>
#include <libssh/legacy.h>
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#define SSHD_USER "user"
#define SSHD_PASSWORD "password"
#define KEYS_FILE "./ssh_host_rsa_key"
/*#ifndef KEYS_FILE
#define KEYS_FILE
#else
#endif*/
static int auth_password(char *user, char *password)
{
if(strcmp(user, SSHD_USER)) {
return 0;
} else {
return 1;
}
if(strcmp(password, SSHD_PASSWORD)) {
return 0;
} else {
return 1;
}
return 0;
}
int …Run Code Online (Sandbox Code Playgroud)