You are not logged in.

#1 2013-08-12 00:12:59

filk
Member
Registered: 2013-02-15
Posts: 15

Can't ssh from remote machine

Hey all,

I enabled sshd on my machine. I can ssh from localhost, but if I try to ssh from another machine I get "operation timed out". Pinging the machine works fine, and the output of "netstat -antp |grep 22" is:

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp        1      0 192.168.1.7:55601       23.75.81.224:80         CLOSE_WAIT  3149/chrome         
tcp        0      0 192.168.1.7:60019       173.194.43.122:80       ESTABLISHED 880/chrome          
tcp        0      0 192.168.1.7:55608       23.75.81.224:80         ESTABLISHED 3149/chrome         
tcp        0      0 192.168.1.7:57018       74.125.192.125:5222     ESTABLISHED 880/chrome          
tcp        0      0 192.168.1.7:55600       23.75.81.224:80         ESTABLISHED 3149/chrome         
tcp        0      0 192.168.1.7:46745       74.125.226.195:443      ESTABLISHED 880/chrome          
tcp6       0      0 :::22                   :::*                    LISTEN      -

Offline

#2 2013-08-12 00:34:40

Multimoon
Member
From: /usr/share/zoneinfo/US/Eastern
Registered: 2012-09-30
Posts: 170

Re: Can't ssh from remote machine

I hate to state the obvious that you probably already did, but did you read the wiki on OpenSSH?
Alot of times there is just something you forgot to configure.

Last edited by Multimoon (2013-08-12 00:35:49)


It always makes me laugh when people complain and rage over any distro's management ideal, when this is a linux community, and you could always make your own distro and experience the pains yourself.

Offline

#3 2013-08-12 02:15:55

filk
Member
Registered: 2013-02-15
Posts: 15

Re: Can't ssh from remote machine

I did read it, and I'm fairly confident I didn't miss anything...

Offline

#4 2013-08-12 03:00:05

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: Can't ssh from remote machine

You need to explain what you did if you want people to stand a chance of helping. Saying you "enabled sshd on my machine" doesn't say anything about how you did it or how you've set things up. What's in sshd_config, for example? Similarly for 'ssh from another machine I get "operation timed out"' - which machine (another machine on the LAN? a machine somewhere else?) which command? Similarly, you don't say anything about your network. Are you using a router? Is it configured? Running a firewall? Which rules?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#5 2013-08-12 09:38:03

jv2112
Member
Registered: 2011-07-23
Posts: 160

Re: Can't ssh from remote machine

Start the process at both ends ?

systemctl enable sshd.service 

Life is pleasant. Death is peaceful. It's the transition that's troublesome. Isaac Asimov - / -

Offline

#6 2013-08-12 13:07:57

m20554443
Member
Registered: 2011-07-01
Posts: 7

Re: Can't ssh from remote machine

jv2112 wrote:

Start the process at both ends ?

systemctl enable sshd.service 

Why? Maybe i do not understand your recommendation correctly, but this is not necessarily what you want. You want to enable sshd on the remote machine(s) you want to connect to. You do not need to enable sshd on the machine you want to connect from - your ssh client will work regardless of whether the daemon is running or not (as long as openssh package is installed of course smile )

Offline

#7 2013-08-12 13:16:43

ganastasiou
Member
Registered: 2010-02-03
Posts: 56

Re: Can't ssh from remote machine

Try from remote machine with ssh -v, to show debug output.

But operation timed out, probably has to do with firewall, if you can ping the ssh server and ofc you are on the same network or an outside network(internet) which server's port is forwarded.

More -v flags, would be more verbose. Maximum is three, -vvv.

Last edited by ganastasiou (2013-08-12 13:26:20)

Offline

#8 2013-08-12 13:53:32

Multimoon
Member
From: /usr/share/zoneinfo/US/Eastern
Registered: 2012-09-30
Posts: 170

Re: Can't ssh from remote machine

Could you post your SSHD config? There are only two things that I could think are at fault, either your router/firewall is blocking the connection, or SSHD is improperly configured. The following information would be useful.
-SSHD config
-Where you are trying to connect from(Another computer, inside LAN, outside, etc.)
-Use a few verbose flags (-v)


It always makes me laugh when people complain and rage over any distro's management ideal, when this is a linux community, and you could always make your own distro and experience the pains yourself.

Offline

#9 2013-08-12 14:47:57

jamesbond007
Member
From: Germany
Registered: 2009-06-14
Posts: 150

Re: Can't ssh from remote machine

Hi filk,

maybe you are running a firewall of some kind, like iptables? Then you have to make sure to open port 22/tcp, otherwise you will not be able to connect from another machine.

You can check if the port is open and reachable from the remote machine using netcat:

netcat -nvz <ip-of-your-machine> 22

If the port is open and ssh is listening on it, you should get the following result:

netcat: <ip-of-your-machine> 22 open

Kind regards,
jamesbond007.

Offline

#10 2013-08-13 00:03:28

Multimoon
Member
From: /usr/share/zoneinfo/US/Eastern
Registered: 2012-09-30
Posts: 170

Re: Can't ssh from remote machine

jamesbond007 wrote:

Hi filk,

maybe you are running a firewall of some kind, like iptables? Then you have to make sure to open port 22/tcp, otherwise you will not be able to connect from another machine.

If he's going from Machine1 -> Machine2 over LAN, opening a port isnt neccesary. Ports only need to be opened if he intends on SSHing from outside his LAN network.


It always makes me laugh when people complain and rage over any distro's management ideal, when this is a linux community, and you could always make your own distro and experience the pains yourself.

Offline

#11 2013-08-13 00:05:22

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Can't ssh from remote machine

Multimoon wrote:
jamesbond007 wrote:

Hi filk,

maybe you are running a firewall of some kind, like iptables? Then you have to make sure to open port 22/tcp, otherwise you will not be able to connect from another machine.

If he's going from Machine1 -> Machine2 over LAN, opening a port isnt neccesary. Ports only need to be opened if he intends on SSHing from outside his LAN network.

Not if he has closed them with a firewall/iptables rule...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#12 2013-08-13 00:08:48

Multimoon
Member
From: /usr/share/zoneinfo/US/Eastern
Registered: 2012-09-30
Posts: 170

Re: Can't ssh from remote machine

jasonwryan wrote:
Multimoon wrote:
jamesbond007 wrote:

Hi filk,

maybe you are running a firewall of some kind, like iptables? Then you have to make sure to open port 22/tcp, otherwise you will not be able to connect from another machine.

If he's going from Machine1 -> Machine2 over LAN, opening a port isnt neccesary. Ports only need to be opened if he intends on SSHing from outside his LAN network.

Not if he has closed them with a firewall/iptables rule...

Thats alot of quotes. I assumed he would have told us had he had a iptables setup going on.


It always makes me laugh when people complain and rage over any distro's management ideal, when this is a linux community, and you could always make your own distro and experience the pains yourself.

Offline

#13 2013-08-13 00:12:48

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: Can't ssh from remote machine

Maybe it is time to see if the OP returns? Right now, it's just a guessing game...


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#14 2013-08-13 02:23:26

filk
Member
Registered: 2013-02-15
Posts: 15

Re: Can't ssh from remote machine

Thanks so much for the attention and replies. I'm sorry I didn't respond faster.

As I was compiling this information, I realized the problem was something different than I thought it was. I'll leave the information at the bottom of the post in case it helps with this next question.

It turns out the SSH works fine - what doesn't work is hostname resolution to the IP address. For some reason, my hostname (let's call it "banana") resolves to a definitely not-local IP: 65. 215.xx.xxx. The IP of the machine with hostname "banana" is 192.168.1.7. For some reason I was under the impression hostname resolution would work on a LAN. Do I have to give the target machine a static IP instead?

-----

Hi all, thanks for the replies. I'll try and address everything in this post.

Here's my sshd_config. It's just the default:

#	$OpenBSD: sshd_config,v 1.89 2013/02/06 00:20:42 dtucker Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
#Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#RSAAuthentication yes
#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile	.ssh/authorized_keys

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no

# Change to no to disable s/key passwords
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'yes' to enable PAM authentication, account processing, 
# and session processing. If this is enabled, PAM authentication will 
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
PrintMotd no # pam does that
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
UsePrivilegeSeparation sandbox		# Default for new installations.
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem	sftp	/usr/lib/ssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#	X11Forwarding no
#	AllowTcpForwarding no
#	ForceCommand cvs server

Both machines are on the same LAN. I have a Raspberry Pi that's connected to the router and accessible to the outside world via SSH. I'd like to be able to SSH into a second machine on the LAN from the pi (I am also working on waking the second machine, a more power-hungry beast, over LAN).

I am using a Netgear WNR3500Lv2 router with stock firmware. As far as I can tell there is no firewall. Port 22 is forwarded to the Raspberry pi.

This is the output of ssh -v on the remote machine (the pi):

OpenSSH_5.9p1, OpenSSL 0.9.8x 10 May 2012
debug1: Reading configuration data /Users/fil/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 53: Applying options for *
debug1: Connecting to pariah [67.215.65.132] port 22.
debug1: connect to address 67.215.65.132 port 22: Operation timed out
ssh: connect to host pariah port 22: Operation timed out

Last edited by filk (2013-08-13 02:25:52)

Offline

#15 2013-08-13 02:33:37

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: Can't ssh from remote machine

So why not just ssh to the LAN ip address?

EDIT: You can probably tell the router to always give that machine the same ip. My router ignores it but I assume you are likely to be luckier. Then you can use an alias in ssh_config on the pi to avoid having to type out the ip all the time.

Last edited by cfr (2013-08-13 02:35:39)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#16 2013-08-14 09:52:03

spyrocete
Member
Registered: 2013-08-14
Posts: 4

Re: Can't ssh from remote machine

You can map a hostname to an ip address but the problem is I only know how to do it in windows. You might be able to edit this file /etc/hosts and it will allow you to put whatever hostname you want with whatever ip address you want.

Last edited by spyrocete (2013-08-14 09:55:46)

Offline

Board footer

Powered by FluxBB