I have a raspberry pi running raspbian. I have a 3G modem connected to it, as well as ethernet. It is set up to use the modem instead of the ethernet, just in case the modem fails, I can use the ethernet. However, I cannot ssh in with the mobile card, I have to use ethernet. How can I ssh in while the mobile card is running?
Reverse SSH is one option:
I'd prefer to just be able to straight up SSH, personally, so I'd try to get that working if I could. I suspect the issue that you're having is that you don't know the IP address the 3G modem is assigned, or that you can't get the modem to forward ports correctly to the RPi.
I would start by signing up with a service like NoIP so that you can give your RPi a dynamic domain name (eg, yourpi.noip.me). Be sure to install their dynamic update client on your RPi so that it gets updated with the IP address assigned to the 3G modem.
Then, try to SSH to that domain name that you set up. If you still can't get through, try researching your 3G modem to see if it uses NAT or some kind of firewall that prevents outside traffic from coming in, and if you can subsequently bypass that.
I had exact same problem. Reason why you cannot connect to RPi during running 3G modem is default gateway.
Let me explain, when you are connected to 3G and ethernet together, packet arrives e.g. from 192.168.0.100 to your RaspberryPi ethernet interface - e.g. 192.168.0.101. Raspberry Pi responds and send packet to interface in routing table. In case of active 3G connection it sends packet to default gateway (3G dongle) which cannot route private IP address to your computer back so you won't see any response from RPi.
To solve this you can use different metric or rule based routing. Personally I use rule based routing, so I route all traffic coming from ethernet port back to ethernet so I can login to my Raspberry Pi even when I am connected to internet using 3G dongle.
See this example (you can add it to end of file /etc/rc.local and reboot your Raspberry Pi)
# Never route local traffic through 3G dongle ip route add table 42 default via 192.168.0.1 ip rule add from 192.168.0.0/24 table 42
Just change 192.168.0.1 to your local ethernet gateway and 192.168.0.0/24 to your local network and it should works like magic.