0

I'm trying to connect to my raspberry pi outside my local network with ssh.

I can connect inside my local network.

My pi has a fixed ip address and port forwarding is set properly.

My ssh port has been changed from 22 to another one, which was free.

The command I am using:

ssh -vvvp 49100 pi@**.***.**.*

Here is the verbose output of ssh command:

OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to **.***.**.* port 49100.
debug1: Connection established.
debug1: identity file /Users/armandfardeau/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /Users/armandfardeau/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/armandfardeau/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/armandfardeau/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/armandfardeau/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/armandfardeau/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/armandfardeau/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/armandfardeau/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4p1 Raspbian-10+deb9u3
debug1: match: OpenSSH_7.4p1 Raspbian-10+deb9u3 pat OpenSSH* compat 0x04000000
debug3: fd 5 is O_NONBLOCK
debug1: Authenticating to **.***.**.*:49100 as 'pi'
debug3: put_host_port: [**.***.**.*]:49100
debug3: hostkeys_foreach: reading file "/Users/armandfardeau/.ssh/known_hosts"
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent

Do you have any idea what the problem is?

2
  • looks like connection is dropped, check forwarding rule 49100@external.ip => 22@pi.address (or 49100@pi.adress) – Archemar Jul 26 '18 at 8:20
  • Does running sudo dpkg-reconfigure openssh-server in the raspbian side solve your problem? – Rui F Ribeiro Jul 26 '18 at 13:38
0

The issue looks like well known MTU/fragmentation problem. Replace MTU for both ssh-server and ssh-client network interfaces with a same smaller value. Let's assume your network interface ssh listens is eth0 (detect it using ifconfig). Check current MTU value for the interface:

cat /sys/class/net/eth0/mtu

Replace temporarily your current MTU (which is 1500 probably) for the interface with a lesser number, for example:

sudo ifconfig eth0 mtu 1496

or

echo 1496 | sudo tee /sys/class/net/eth0/mtu

If the number 1496 hasn't solved problem, try MTU 1250 etc. If the problem goes away with some MTU value, make the changes for interface persistent.

Read this carefully: http://www.snailbook.com/faq/mtu-mismatch.auto.html

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.