SSH takes so long to enter shell

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face: is for home/non-enterprise users. If you’re running a business, paid support can be accessed via where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:


Or for longer, use three backticks above and below the code snippet:


Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

I am using NextcloudPi vanilla 1.53.0 and I encountered strange problems with SSH.
I found it takes so long to SSH my RaspberryPi now, I tried with -vv and here is what I got (I replaced my real IP with :

charles@'s password: 
debug2: we sent a password packet, wait for reply
debug1: Authentication succeeded (password).
Authenticated to ([]:22).
debug1: channel 0: new [client-session]
debug2: channel 0: send open
debug1: Requesting
debug1: Entering interactive session.
debug1: pledge: network

### And here it stucks for 1 to 2 minutes ###

debug1: client_input_global_request: rtype want_reply 0
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: fd 3 setting TCP_NODELAY
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug1: Sending environment.
debug1: Sending env LANG = en_GB.UTF-8
debug2: channel 0: request env confirm 0
debug2: channel 0: request shell confirm 1
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0

### Shell appears ###

Is this the first time you’ve seen this error? (Y/N): No.

As a matter of fact, I tried to burn a new NextcloudPi 1.53.0 on my SD card and the problem persists.

Steps to replicate it:

  1. Download the NCP 1.53.0 zip package from Releases · nextcloud/nextcloudpi · GitHub .
  2. Burn it to an empty SD card using RaspberryPi Imager, and in its “custom settings” set your account name & passwd and check the Enable SSH box.
  3. Insert the card to RaspberryPi and power it on, try to connect it via SSH.

I tried journalctl -r and the result makes me confused: it shows nothing suspicious.
This is the record of what happened when I tried to self-SSH the Rasp-Pi using established SSH from my PC.

Jan 20 20:47:50 raspberry-pi sshd[2960]: Starting session: shell on pts/2 for charles from port 34030 id 0
Jan 20 20:47:50 raspberry-pi sshd[2911]: User child is on pid 2960
Jan 20 20:45:40 raspberry-pi systemd-logind[445]: New session 11 of user charles.
Jan 20 20:45:40 raspberry-pi systemd[1]: Started Session 11 of user charles.
Jan 20 20:45:40 raspberry-pi sshd[2911]: pam_unix(sshd:session): session opened for user charles(uid=1000) by (uid=0)
Jan 20 20:45:40 raspberry-pi sshd[2911]: Accepted password for charles from port 34030 ssh2
Jan 20 20:45:33 raspberry-pi sshd[2911]: Connection from port 34030 on port 22 rdomain ""

As you can see there is a 1 minute delay.

For this happens on a system with Nextcloud NOT activated, I did not check NC logs. I did not modify any part of the system after powered on, either.

I would really appreciate it if anyone could look into this and give me a hint on what I should do next.
P.S.: This is my first time on this forum and I am not a native English speaker. Please let me know if there’s anything confusing about my expressions or any further information is needed.

For hardware, I use a RaspberryPi 4B with 8G RAM and it’s connected to my router using a wire for Internet connection.

And before I reinstall the system, I found that when / is mounted as 'ro' on boot by adding 'fsck' option in /etc/fstab, the SSH could establish quickly as usual.
But as soon as I remount the root partition as 'rw', things become weird.
I thought there is something wrong with my system after an upgrade, so I reinstalled the latest NCP and it is of no use.

My microHDMI to HDMI adapter arrived yesterday so I was finally able to connect my Rasp-Pi to a monitor.
It turns out that when I entered my username and password and pressed enter in TTY, it would also stuck for a while… However this time I simply typed ^C via a USB keyboard connected to Rasp-Pi, and Here is what I got:
grep: failed to fetch /var/run/.ncp-latest-version : No such file or directory

It seems every time before shell appears the system tried to read /var/run/.ncp-latest-version but for some unknown reason the file simply does not appear in my system.
So the solution is simple:

  1. Write a script which contains echo "Here it is." > /var/run/.ncp-latest-version
  2. Write a .service file to make sure that the script runs every time the system boots up. Notice to set User=root in the [Service] section for the file can only be written with root privilege. And touch simply would not work for the file seems must not be empty.

And then the system would run well, the NCP logo and update notification (NextCloudPi v1.53.0 is up to date) would also display normally.


This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.