You are not logged in.

#1 2022-07-31 07:15:48

variable-root
Member
Registered: 2022-06-04
Posts: 13

[SOLVED] SSH issue

Hello,

I have two arch devices (client and server) which I am attempting to connect to via SSH. The issue is however that I can only connect to the server if a local login is already established.

ssh -V
OpenSSH_9.0p1, OpenSSL 1.1.1q  5 Jul 2022

The versions are the same for both client and server. The SSH connection works if I am already
logged in at the server, however if I do not:

$PS1:[41]~ $ ssh -v SERVER                                                          
OpenSSH_9.0p1, OpenSSL 1.1.1q  5 Jul 2022                                                             
debug1: Reading configuration data /home/USER/.ssh/config                                          
debug1: /home/USER/.ssh/config line 4: Applying options for SERVER
debug1: Reading configuration data /etc/ssh/ssh_config                                                
debug1: Connecting to 192.168.0.20 [192.168.0.20] port 22.                                           
debug1: connect to address 192.168.0.20 port 22: No route to host                                    
ssh: connect to host 192.168.0.20 port 22: No route to host

There was no journalctl output. Any help is appreciated.

Last edited by variable-root (2022-08-03 00:58:32)

Offline

#2 2022-07-31 08:06:27

Grigorios
Member
Registered: 2021-01-10
Posts: 27

Re: [SOLVED] SSH issue

Hello,

I have never heard of the problem that you cannot connect to a system via ssh if no user is locally logged in.

Based on your ssh -V Server output, we can see that your system has no route to the SERVER.
Check if both machines are in the same subnet and maybe post the output from

$ip route

and

$ip a

Greetings

Grigorios

Last edited by Grigorios (2022-07-31 08:07:46)

Offline

#3 2022-07-31 15:09:43

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,665

Re: [SOLVED] SSH issue

My SWAG (Scientific Wild Ass Guess):  The server is using a WiFi connection? You are using something on the server to control the Network connection that is based not on system level credentials, but rather user level credentials:  Like i3wm with NetworkManager?  If this is the case, the Network connection will not associate until the user logs in.  You can check that by checking the journal.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#4 2022-07-31 17:34:45

PerfMonk
Member
Registered: 2016-04-21
Posts: 23

Re: [SOLVED] SSH issue

Is the server and/or client are virtual machines on same host ?
Normally a VM has no route to reach its host, it just gives you a gateway access to internet.

Offline

#5 2022-08-01 03:45:32

variable-root
Member
Registered: 2022-06-04
Posts: 13

Re: [SOLVED] SSH issue

@ewaller & @Perfmonk

The server is a ethernet wired seperate station. It is also not a VM but bootable archlinux on the disk.

@Grigorios

For client (with MAC addresses REDACTED for security):

ip route
default via 192.168.0.1 dev wlp2s0 proto dhcp src 192.168.0.50 metric 600 
192.168.0.0/24 dev wlp2s0 proto kernel scope link src 192.168.0.50 metric 600
ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: enp3s0f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether REDACTED
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether REDACTED permaddr REDACTED
    inet 192.168.0.50/24 brd 192.168.0.255 scope global dynamic noprefixroute wlp2s0
       valid_lft 604730sec preferred_lft 604730sec
    inet6 REDACTED scope global dynamic noprefixroute 
       valid_lft 3532sec preferred_lft 3532sec
    inet6 REDACTED scope global dynamic noprefixroute 
       valid_lft 172799sec preferred_lft 172799sec
    inet6 REDACTED scope link noprefixroute 
       valid_lft forever preferred_lft forever

For server:

ip route
default via 192.168.0.1 dev enp33s0 proto dhcp src 192.168.0.20 metric 100 
192.168.0.0/24 dev enp33s0 proto kernel scope link src 192.168.0.20 metric 100
ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp33s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether REDACTED permaddr REDACTED
    inet 192.168.0.20/24 brd 192.168.0.255 scope global dynamic noprefixroute enp33s0
       valid_lft 534074sec preferred_lft 534074sec

It is a strange issue, and unfortunately the few posts made by other users various forums are all dead ends as well.

Offline

#6 2022-08-01 06:42:37

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,506

Re: [SOLVED] SSH issue

ssh: connect to host 192.168.0.20 port 22: No route to host

is either a really weird bug in the ssh client or obvious.
W/o being logged into the server (what I understand is the problematic condition, it's NOT that you first need to locally log into the client, right?)

ip r 192.168.0.20
ping -c 192.168.0.20
nmap -p 192.168.0.20

Do you configure a static IP on the server?
How is the NIC configured to begin with (you could still eg. be activating w/ a user service - wifi or not)?

It's *only* about being logged into the server, you're positive (not "I think", *know*) that it's up, running and not in S3?
=> Try to disable the NICs power saving, set /sys/class/net/enp33s0/power/control to "on", https://wiki.archlinux.org/title/Power_ … Management
or disable aspm altogether (for a quick test), "pcie_aspm=off", https://wiki.archlinux.org/title/Kernel_parameters

Offline

#7 2022-08-02 07:51:40

variable-root
Member
Registered: 2022-06-04
Posts: 13

Re: [SOLVED] SSH issue

@seth

The current server behavior is to only allow a valid remote ssh connection from the client if the client is already logged in locally.
The desired server behavior is to allow a valid remote ssh connection from the client after the server completes booting (multi-user.target).

I have reinstalled open-ssh on both the client and server. I have moved the authorized_keys file outside the user home directory. As you suggested I also:
Disabled the NICs power-saving by setting set /sys/class/net/enp33s0/power/control to "on" from "auto".
Set pcie_aspm=off during boot. Unfortunately, none of these steps resolved the issue.

Using the ping command, and root login I was able to determine - as you suspected - that NIC configuration seems to only be happening when the user
is logged in. As soon as the user logs out the NIC releases the static IP and goes down. I am not certain as to why since NIC configuration is handled by NetworkManager.service which
is a target.wants of multi-user.

After boot without local user login:
http://ix.io/46q7
http://ix.io/46q8

Offline

#8 2022-08-02 09:09:31

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED] SSH issue

But how is the connection configured in NM? I remember that nm-connection-editor has a checkbox with something like "allow all users to connect". If that is unchecked, I think it would explain this behavior.

Offline

#9 2022-08-02 11:54:59

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,506

Re: [SOLVED] SSH issue

Aug 02 03:25:51 HOSTNAME_REDACTED NetworkManager[520]: <info>  [1659410751.4985] device (enp33s0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')

find /etc/systemd -type l -exec test -f {} \; -print | awk -F'/' '{ printf ("%-40s | %s\n", $(NF-0), $(NF-1)) }' | sort -f

Otherwise see https://wiki.archlinux.org/title/Networ … ic_devices

Offline

#10 2022-08-03 00:57:30

variable-root
Member
Registered: 2022-06-04
Posts: 13

Re: [SOLVED] SSH issue

@Raynman

This turned out to be exactly the issue. After setting the option I was able to ssh into the server without login as desired.

Thank you all for the help.

Offline

#11 2022-08-03 05:37:29

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,506

Re: [SOLVED] SSH issue

enp33s0 is an ethernet NIC and afaiu NM this doesn't require sharing.
There might be a conflicting service or you blocked the NIC from autoconnection.
=> see #9

Also, ftr. w/ only one wired NIC being autoconnected and on a server, you don't need NM at all - just dhcpcd will do.

Offline

Board footer

Powered by FluxBB