1

On a Debian Stretch VM (running in VirtualBox on a Windows 7 host), I would like to connect via SSH to a specific remote host (let's call it myServer, with IP 12.34.56.78). To do so, I'm using my Android smartphone as a USB modem, which works fine : I can reach the internet and generate some 'ping' and HTTP/HTTPS traffic, and even open an SSH connection with a command like :

ssh httqm@12.34.56.78 -b a.b.c.d -p portNumber -i ~/.ssh/id_rsa

NB: a.b.c.d is the dynamic IP address assigned to my USB interface upon connection

To make things easier, I'd like to have all these settings in ~/.ssh/config so that I'll just have to type ssh myServer :

Host myServer
    HostName 12.34.56.78
    Port portNumber
#   BindAddress a.b.c.d     <== commented because this is part of the question
#   BindInterface usb0      <== same as above
    User httqm
    IdentityFile ~/.ssh/id_rsa
  • I can uncomment the BindAddress line and specify the IP address, which works but provides no gain compared to the full SSH command line since a.b.c.d is dynamic
  • using the BindInterface option (without BindAddress) fails with error message :

    ~/.ssh/config: line 154: Bad configuration option: bindinterface
    ~/.ssh/config: terminating, 1 bad configuration options
    

This error message is expected since the BindInterface directive was introduced by Openssh 7.7 (https://www.openssh.com/releasenotes.html) whereas I have :

$ dpkg -l openssh-client
openssh-client      1:7.4p1-10+deb9u6

To workaround this, I'm considering several solutions :

  1. define a route with ip route ... commands so that everything aimed at myServer goes through the USB interface. So far, I've tried commands like this :

    ip route add to 12.34.56.78 protocol static dev usb0
    

The command itself returns no error, but I can't open an SSH connection with ssh myServer, I can't even ping it.

  1. define a Netfilter rule so that all traffic to/from 12.34.56.78 goes through the usb0 interface. Would that even work ? Should I investigate this solution ?

  2. upgrade openssh-client from backports if available

Can you please explain which would / wouldn't work (and why) ? What would you suggest to reach my goal which is to connect to my SSH host with a short command line such as ssh myServer considering my source address is dynamic ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.