【问题标题】:How to set ssh-client port如何设置 ssh-client 端口
【发布时间】:2020-05-31 15:15:32
【问题描述】:

我的问题如下

SSH session - fixed port on the client side

有没有像tcp-client:1234 ------> tcp-server-ssh:22这样的解决方案

【问题讨论】:

  • question that you linked to上的答案有什么问题?
  • 你知道你可以建立一个这样的连接吗?您可以修补 ssh 客户端(扩展现有的 -b 选项),但整个想法没有任何意义(这就是投反对票的原因)。
  • 好的,我想这样做只是因为防火墙,我只能在我的电脑上使用固定端口

标签: ssh


【解决方案1】:

我已经修复它编译openssh,我使用版本openssh-portable-V_8_3_P1

  1. 添加int options.bind_port

  2. 修复 main()

char myaddress[100]={};
.....
    case 'b':
        sscanf(optarg,"%[^:]:%d",myaddress,&options.bind_port);         
        options.bind_address = myaddress;
        break;
  1. sshconnect.c 固定在430
    ((struct sockaddr_in*)&bindaddr)->sin_port= htons(options.bind_port);
    if (bind(sock, (struct sockaddr *)&bindaddr, bindaddrlen) != 0) {
        error("bind %s: %s", ntop, strerror(errno));
        goto fail;
    }
  1. ./configure && make
  2. ln -s .ssh .myssh
  3. 试试
./myssh  -b 192.168.1.153:5566  root@xxx.xyz
  1. 那么你可以看到
vmuser@ubuntu:~$ lsof | grep "myssh.*TCP"
myssh     110179                 vmuser    3u     IPv4            4018314      0t0        TCP ubuntu:5566->myother_ubuntu:ssh (ESTABLISHED)
myssh     110187                 vmuser    3u     IPv4            4017137      0t0        TCP ubuntu:5588->myother_ubuntu:ssh (ESTABLISHED)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-06
    • 1970-01-01
    • 2017-06-22
    • 2019-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多