How do i use SSH outside of my lan

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
foxtreat
Level 2
Level 2
Posts: 52
Joined: Thu Mar 24, 2016 6:44 am
Location: sofia

How do i use SSH outside of my lan

Post by foxtreat » Thu Oct 18, 2018 4:58 pm

i needed to be able to remotely control/move files to my linux mint 17.2 machine from my mint 18.3 machine(only 17.2 runs on the server,)

i did the following on both machines

Code: Select all

sudo apt-get install openssh-server
i then used ifconfig to see the internal ip of my reciever machine(17.2)
found that it is 192.168.0.144
i did this from the sender machine(18.3)

Code: Select all

ssh foxtreat@192.168.0.144
typed yes
i entered my password and it was a success!
i then opened up my router and set up a virtual server port trigger on port 22 external and internal to the ip 192.168.0.144

i then used whatsmyip.org to find my external ip (94.147.x.x)
i then did this from my sender machine

Code: Select all

ssh foxtreat@94.147.x.x
typed yes
it asked for a password like always,i entered it and it
permission denied,please try again
the password is DEFINATELY correct
after 3 tries i recieved this error

Permission denied(publickey,password,keyboard-interactive).

how do i make this work?
i have no prior knowledge to ssh or scp,i just followed a online tutorial,it worked there
help?
Laptop 18.2,fanatic,Gaming,just a average highly hyped user

AscLinux
Level 4
Level 4
Posts: 318
Joined: Sat Oct 29, 2016 3:32 pm

Re: How do i use SSH outside of my lan

Post by AscLinux » Thu Oct 18, 2018 5:59 pm

You can increase client verbosity for debugging.

foxtreat
Level 2
Level 2
Posts: 52
Joined: Thu Mar 24, 2016 6:44 am
Location: sofia

Re: How do i use SSH outside of my lan

Post by foxtreat » Thu Oct 18, 2018 6:21 pm

AscLinux wrote:
Thu Oct 18, 2018 5:59 pm
You can increase client verbosity for debugging.
it took me a while to understand what you means(im not linux savvy)
here is the output of it

Code: Select all

foxtreat@Rogue ~ $ ssh -vvv foxtreat@94.158.x.x
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "94.158.x.x" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 94.158.x.x [94.158.x.x] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/foxtreat/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/foxtreat/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/foxtreat/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/foxtreat/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/foxtreat/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/foxtreat/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/foxtreat/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/foxtreat/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 94.158.x.x:22 as 'foxtreat'
debug3: hostkeys_foreach: reading file "/home/foxtreat/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/foxtreat/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys from 94.158.x.x
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ssh-rsa SHA256:j71Bk+GAAAWxblrNdDg7Ci80iUaK7VzDENJNYykcAXA
debug3: hostkeys_foreach: reading file "/home/foxtreat/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/foxtreat/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys from 94.158.x.x
debug1: Host '94.158.x.x' is known and matches the RSA host key.
debug1: Found key in /home/foxtreat/.ssh/known_hosts:2
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug2: key: /home/foxtreat/.ssh/id_rsa ((nil))
debug2: key: /home/foxtreat/.ssh/id_dsa ((nil))
debug2: key: /home/foxtreat/.ssh/id_ecdsa ((nil))
debug2: key: /home/foxtreat/.ssh/id_ed25519 ((nil))
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/foxtreat/.ssh/id_rsa
debug3: no such identity: /home/foxtreat/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /home/foxtreat/.ssh/id_dsa
debug3: no such identity: /home/foxtreat/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/foxtreat/.ssh/id_ecdsa
debug3: no such identity: /home/foxtreat/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/foxtreat/.ssh/id_ed25519
debug3: no such identity: /home/foxtreat/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug3: send packet: type 50
debug2: we sent a keyboard-interactive packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: userauth_kbdint: disable: no info_req_seen
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: 
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
foxtreat@94.158.x.x's password: 
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
Permission denied, please try again.
foxtreat@94.158.x.x's password: 
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
Permission denied, please try again.
foxtreat@94.158.x.x's password: 
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey,password,keyboard-interactive).
edit: i just dont understand anything from it,it seems to be connecting to the reciever so it isnt a port/router issue
Laptop 18.2,fanatic,Gaming,just a average highly hyped user

User avatar
smurphos
Level 8
Level 8
Posts: 2013
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: How do i use SSH outside of my lan

Post by smurphos » Fri Oct 19, 2018 12:53 am

Well it's connecting to the machine so that rules out issues with firewall, your port forward etc - but it doesn't like your user and/or password.

On the server run cat /etc/ssh/sshd_config and check under the #Authentication section if you've set up allowed users and added your user with the local ip address only. I'm no SSH expert but this is the most obvious possibility...

E.g. I've got - AllowUsers steve@192.168.1.* because i only want it to accept connections from me on my LAN. If I wanted it just to be me but from any IP address it would be AllowUsers steve

Please give serious consideration to setting up a public/private key pair and disabling password authentication if you are going to leave this server internet facing. Password authentication really isn't secure enough in this scenario.

This is a nice SSH guide - https://www.digitalocean.com/community/ ... this-guide

Specifically on key pairs - https://www.digitalocean.com/community/ ... buntu-1604

Also double check you are keeping your server machine fully updated - viewtopic.php?f=61&t=279773

foxtreat
Level 2
Level 2
Posts: 52
Joined: Thu Mar 24, 2016 6:44 am
Location: sofia

Re: How do i use SSH outside of my lan

Post by foxtreat » Fri Oct 19, 2018 8:45 am

smurphos wrote:
Fri Oct 19, 2018 12:53 am
Well it's connecting to the machine so that rules out issues with firewall, your port forward etc - but it doesn't like your user and/or password.

On the server run cat /etc/ssh/sshd_config and check under the #Authentication section if you've set up allowed users and added your user with the local ip address only. I'm no SSH expert but this is the most obvious possibility...

E.g. I've got - AllowUsers steve@192.168.1.* because i only want it to accept connections from me on my LAN. If I wanted it just to be me but from any IP address it would be AllowUsers steve

Please give serious consideration to setting up a public/private key pair and disabling password authentication if you are going to leave this server internet facing. Password authentication really isn't secure enough in this scenario.

This is a nice SSH guide - https://www.digitalocean.com/community/ ... this-guide

Specifically on key pairs - https://www.digitalocean.com/community/ ... buntu-1604

Also double check you are keeping your server machine fully updated - viewtopic.php?f=61&t=279773
did not find anything like Allowusers or #authentication,opened it through a GUI text editor to check with ctrl+F and it confirms i have no such thing in my file,checked ssh_config aswell but allas nothing of the sorts is there,but im certain i havent set up anything of the sorts manually
i will check the guides for help aswell


update:i followed the first tutorial
i then loged onto my server from my client through the local ip(192.168.0.144)
it worked
i then atempted it from my external ip (94.x.x.x) and it again gave me the same error,i tried to transfer the key through the external ip,but it just keeps giving the same fricking error

second tutorial is mostly the same as the first

the server is fully updated except for the kernel due to issues with newer kernels

i switched out and made my server machine the client and the client machine a server
i changed the port forwarding fro the .144 ip to the .129 ip(my current server)

the issue remains it just keeps spamming Permission denied when the password is correct and then Permission denied(publickey,password,keyboard-interactive)
WHY IS IT SO CUMBERSOME
it did do the whole Rsa key fingerprint are you sure you wanna continue and i said yes,so it again can connect to the server
Im getting real pissed at it,ive been bothering with this for 4 days now and i will just install windows 7 on the server and not bother with all the graphical issues and Permission denied B******t
any last ditch ideas? i do not care a single bit about security or any passwords or keys i just want it to work
Laptop 18.2,fanatic,Gaming,just a average highly hyped user

AscLinux
Level 4
Level 4
Posts: 318
Joined: Sat Oct 29, 2016 3:32 pm

Re: How do i use SSH outside of my lan

Post by AscLinux » Fri Oct 19, 2018 9:45 am

Not sure what's going on there, I have used SSH for decades to work remotely and never had nay issues I couldn't resolve. You could use key-based authentication (which is recommended anyway as more secure), but you need to copy the keys by hand before you attempt remote connection. My guess is something goes wrong with port forwarding. What device is doing your NAT and are there any other restrictions in place? Perhaps this device is accepting SSH connections by itself? You could use port 40 as outside port and forward this to port 22 of your LAN machine. Then you can be sure your router is not interfering.

foxtreat
Level 2
Level 2
Posts: 52
Joined: Thu Mar 24, 2016 6:44 am
Location: sofia

Re: How do i use SSH outside of my lan

Post by foxtreat » Fri Oct 19, 2018 3:20 pm

AscLinux wrote:
Fri Oct 19, 2018 9:45 am
Not sure what's going on there, I have used SSH for decades to work remotely and never had nay issues I couldn't resolve. You could use key-based authentication (which is recommended anyway as more secure), but you need to copy the keys by hand before you attempt remote connection. My guess is something goes wrong with port forwarding. What device is doing your NAT and are there any other restrictions in place? Perhaps this device is accepting SSH connections by itself? You could use port 40 as outside port and forward this to port 22 of your LAN machine. Then you can be sure your router is not interfering.
it seems to be able to connect to the server as if i do not set up port forwarding it just hangs

i tried using keys but the only worked on lan,
im certain port forwarding is set up correctly
im using some alien looking TP-link router
it is just too infuriating to bother anymore,i just reinstalled windows 7 on the server and followed tutorials on that part to make it work the way i need to,it did work although painfully
took less than 4 and a half days though
Laptop 18.2,fanatic,Gaming,just a average highly hyped user

Post Reply

Return to “Newbie Questions”