vscode连接服务器一直显示opening Remote

今天连接服务器的时候一直连接不上,但是其他用户的号可以正常连接,就去查了一下,然后把服务器的/home/用户名/.vscode-server删除就完美解决了!

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
连接 SSH 服务器,需要使用 SSH 客户端,例如 OpenSSH。在 C 语言中,可以使用 libssh 库来实现 SSH 连接和通信。 以下是一个简单的 C 语言程序,使用 libssh 库连接到 SSH 服务器并执行命令: ```c #include <stdio.h> #include <stdlib.h> #include <libssh/libssh.h> int main() { ssh_session my_ssh_session; int rc; my_ssh_session = ssh_new(); if (my_ssh_session == NULL) { fprintf(stderr, "Error creating SSH session\n"); exit(1); } ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "example.com"); ssh_options_set(my_ssh_session, SSH_OPTIONS_USER, "username"); rc = ssh_connect(my_ssh_session); if (rc != SSH_OK) { fprintf(stderr, "Error connecting to SSH server: %s\n", ssh_get_error(my_ssh_session)); ssh_free(my_ssh_session); exit(1); } rc = ssh_userauth_password(my_ssh_session, NULL, "password"); if (rc != SSH_AUTH_SUCCESS) { fprintf(stderr, "Error authenticating with SSH server: %s\n", ssh_get_error(my_ssh_session)); ssh_disconnect(my_ssh_session); ssh_free(my_ssh_session); exit(1); } ssh_channel channel; int nbytes; char buffer[256]; channel = ssh_channel_new(my_ssh_session); if (channel == NULL) { fprintf(stderr, "Error creating SSH channel\n"); ssh_disconnect(my_ssh_session); ssh_free(my_ssh_session); exit(1); } rc = ssh_channel_open_session(channel); if (rc != SSH_OK) { fprintf(stderr, "Error opening SSH channel: %s\n", ssh_get_error(my_ssh_session)); ssh_channel_free(channel); ssh_disconnect(my_ssh_session); ssh_free(my_ssh_session); exit(1); } rc = ssh_channel_request_exec(channel, "ls -l"); if (rc != SSH_OK) { fprintf(stderr, "Error executing command on SSH channel: %s\n", ssh_get_error(my_ssh_session)); ssh_channel_close(channel); ssh_channel_free(channel); ssh_disconnect(my_ssh_session); ssh_free(my_ssh_session); exit(1); } nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0); while (nbytes > 0) { fwrite(buffer, 1, nbytes, stdout); nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0); } ssh_channel_send_eof(channel); ssh_channel_close(channel); ssh_channel_free(channel); ssh_disconnect(my_ssh_session); ssh_free(my_ssh_session); return 0; } ``` 在上面的示例中,使用 `ssh_options_set()` 函数设置 SSH 服务器的主机名和用户名,使用 `ssh_connect()` 函数连接到 SSH 服务器,使用 `ssh_userauth_password()` 函数进行密码身份验证。然后使用 `ssh_channel_new()` 函数创建 SSH 通道,使用 `ssh_channel_open_session()` 函数打开会话通道,使用 `ssh_channel_request_exec()` 函数在通道上执行命令,并使用 `ssh_channel_read()` 函数读取命令输出。最后关闭通道和 SSH 会话。 请注意,该示例中使用密码进行身份验证,这并不安全。建议使用 SSH 密钥身份验证来提高安全性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值