gpt4 book ai didi

c - 来自 C 的 Linux SSH

转载 作者:行者123 更新时间:2023-11-30 19:19:43 27 4
gpt4 key购买 nike

我正在使用 SSH 通过 C 文件连接到其他计算机。在终端中我使用此代码

ssh sakurachan@192.168.61.10

如何用 C 语言做到这一点?我需要用户输入IP和计算机。目前我有这个代码:

char name[100];
char ip[100];
printf("Enter the computer name to connect: ");
scanf("%s", name);
printf("Enter the ip to connect: ");
scanf("%s", ip);
char command[150];
strcpy(command, "ssh ");
strcat(command, name);
system(command);

代码无法运行。有什么办法可以解决这个问题吗?

最佳答案

您可以使用libssh如果您正在使用 C 进行编程并使用适当的 C 函数来执行此操作。在 C 中进行攻击是相当丑陋的(恕我直言)。

libssh 有非常好的文档并且很好 tutorials 。试试这个。

关于c - 来自 C 的 Linux SSH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23824084/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com