You are not logged in.

#1 2023-10-02 07:30:49

love4taylor
Member
From: China
Registered: 2023-09-12
Posts: 5
Website

Logging in via ssh, the w command does not show the TTY number

Including the FROM and WHAT columns for specific commands will only show sshd

root@egoist ~ # w
 16:26:05 up  1:18,  1 user,  load average: 0.00, 0.00, 0.00
USER     TTY       LOGIN@   IDLE   JCPU   PCPU  WHAT
root               16:15    1:17m  0.00s  0.09s sshd: root@pts/0

Offline

#2 2023-10-02 12:57:00

seth
Member
Registered: 2012-09-03
Posts: 52,477

Re: Logging in via ssh, the w command does not show the TTY number

It won't ever show a TTY because you're on a PTS, however, couple of things:
1. why does it show "sshd" and not "ssh"?
2. why are you logged in as root via ssh?

What is the client from which you log in ("sshd: root@pts/0" looks weird) and what's the output of

systemctl status sshd

Offline

#3 2023-10-02 13:14:18

love4taylor
Member
From: China
Registered: 2023-09-12
Posts: 5
Website

Re: Logging in via ssh, the w command does not show the TTY number

seth wrote:

It won't ever show a TTY because you're on a PTS

I don't see the relevance, it shows up fine on other distros like Ubuntu and Debian.

palaych@au-tokyo-builder1:~$ w
 22:04:05 up 1 day,  3:24,  1 user,  load average: 0.50, 0.30, 0.21
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
palaych  pts/0    xxx.xxx.xx.xxx   22:04    1.00s  0.12s  0.03s w
seth wrote:

1. why does it show "sshd" and not "ssh"?

openssh provides remote login via "sshd" binaries

seth wrote:

2. why are you logged in as root via ssh?

The vps provider offers root login by default, but I don't think that's relevant.

seth wrote:

What is the client from which you log in ("sshd: root@pts/0" looks weird)

Client: openssh on macOS

output of systemctl status sshd

● sshd.service - OpenSSH Daemon
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; preset: disabled)
     Active: active (running) since Mon 2023-10-02 20:16:01 JST; 1h 46min ago
   Main PID: 367 (sshd)
      Tasks: 1 (limit: 1138)
     Memory: 6.2M
        CPU: 216ms
     CGroup: /system.slice/sshd.service
             └─367 "sshd: /usr/bin/sshd -D [listener] 0 of 10-100 startups"

Oct 02 20:16:01 egoist sshd[367]: Server listening on 0.0.0.0 port 23333.
Oct 02 20:16:01 egoist sshd[367]: Server listening on :: port 23333.
Oct 02 20:16:02 egoist sshd[374]: Accepted publickey for root from xxx.xx.xxx.xxx port 8561 ssh2: ED25519 SHA256:wqK61LOy7F>
Oct 02 20:16:02 egoist sshd[374]: pam_unix(sshd:session): session opened for user root(uid=0) by root(uid=0)
Oct 02 20:21:56 egoist sshd[618]: Accepted publickey for root from xxx.xx.xxx.xxx port 8334 ssh2: ED25519 SHA256:wqK61LOy7F>
Oct 02 20:21:56 egoist sshd[618]: pam_unix(sshd:session): session opened for user root(uid=0) by root(uid=0)
Oct 02 21:53:00 egoist sshd[690]: Accepted publickey for root from xxx.xx.xxx.xxx port 8229 ssh2: ED25519 SHA256:wqK61LOy7F>
Oct 02 21:53:00 egoist sshd[690]: pam_unix(sshd:session): session opened for user root(uid=0) by root(uid=0)
Oct 02 22:02:12 egoist sshd[1162]: Accepted publickey for root from xxx.xx.xxx.xxx port 8496 ssh2: ED25519 SHA256:wqK61LOy7>
Oct 02 22:02:12 egoist sshd[1162]: pam_unix(sshd:session): session opened for user root(uid=0) by root(uid=0)

The following was installed by me running archinstall through the official archlinux iso, but still have this problem.

love4taylor@au-tokyo-n1 ~ $ w
 13:11:24 up  1:42,  1 user,  load average: 0.00, 0.00, 0.00
USER     TTY       LOGIN@   IDLE   JCPU   PCPU  WHAT
love4tay           13:11    1:42m  0.00s  0.01s sshd: love4taylor [priv]
love4taylor@au-tokyo-n1 ~ $ neofetch 
                   -`                    love4taylor@au-tokyo-n1.love4taylor.com 
                  .o+`                   --------------------------------------- 
                 `ooo/                   OS: Arch Linux x86_64 
                `+oooo:                  Host: VMware20,1 None 
               `+oooooo:                 Kernel: 6.5.5-arch1-1 
               -+oooooo+:                Uptime: 1 hour, 42 mins 
             `/:-:++oooo+:               Packages: 257 (pacman) 
            `/++++/+++++++:              Shell: bash 5.1.16 
           `/++++++++++++++:             Resolution: 1280x800 
          `/+++ooooooooooooo/`           Terminal: /dev/pts/0 
         ./ooosssso++osssssso+`          CPU: Intel Xeon E5-2676 v3 (48) @ 2.394GHz 
        .oossssso-````/ossssss+`         GPU: 00:0f.0 VMware SVGA II Adapter 
       -osssssso.      :ssssssso.        Memory: 1470MiB / 16007MiB 
      :osssssss/        osssso+++.
     /ossssssss/        +ssssooo/-                               
   `/ossssso+/:-        -:/+osssso+-                             
  `+sso+:-`                 `.-/+oso:
 `++:.                           `-/+/
 .`                                 `/

Offline

#4 2023-10-02 15:15:50

seth
Member
Registered: 2012-09-03
Posts: 52,477

Re: Logging in via ssh, the w command does not show the TTY number

openssh provides remote login via "sshd" binaries

sshd is the daemon and you're not supposed to run that - it gets socket-triggered by the sshd.service
You login w/ ssh, not sshd.

Client: openssh on macOS

How exactly?

ssh -l love4tay <arch_ip_here>

The vps provider offers root login by default, but I don't think that's relevant.

No, it's just insanely insecure - and stupid.
Please disable that.

Offline

#5 2023-10-02 16:44:11

love4taylor
Member
From: China
Registered: 2023-09-12
Posts: 5
Website

Re: Logging in via ssh, the w command does not show the TTY number

seth wrote:

sshd is the daemon and you're not supposed to run that - it gets socket-triggered by the sshd.service
You login w/ ssh, not sshd.

I don't want to talk pedantically so this is the last time this part will be discussed. In context, sshd appears in the WHAT column, and then you ask why sshd, it's a remote host, and of course I'm connecting to a service provided by sshd, and the reason for displaying sshd is essentially that the w command doesn't correctly display commands run by the user. It only shows me the sshd processes I'm connected to.

seth wrote:

ssh -l

It doesn't solve the problem.

seth wrote:

No, it's just insanely insecure - and stupid.
Please disable that.

I'm not a newbie to Linux, and I'm certainly aware of the security specification. But first of all this is not a production server, and it's not even commonly used. And I always turn off passwords and just use keys.

I think we've gotten off topic.

Offline

#6 2023-10-02 18:17:19

seth
Member
Registered: 2012-09-03
Posts: 52,477

Re: Logging in via ssh, the w command does not show the TTY number

It only shows me the sshd processes I'm connected to.

Which is not what's happening here. That's why I'm asking.
(I get the remote host and process name, ssh)
Maybe post your sshd_config (which is where the root login becomes on topic, because it would have been prohibited for password logins by the default config)
Are you btw. logging in from the host of the VM?
What happens if you ssh-login locally?

ssh localhost; w

Edit: what "problem", btw?
Assuming this depends on the client and you'll simply not get the PTS, what problem are you actually trying to solve?
https://en.wikipedia.org/wiki/XY_problem

Last edited by seth (2023-10-02 18:37:43)

Offline

#7 2023-10-03 04:42:06

love4taylor
Member
From: China
Registered: 2023-09-12
Posts: 5
Website

Re: Logging in via ssh, the w command does not show the TTY number

seth wrote:

Maybe post your sshd_config

https://gist.github.com/love4taylor/e5d … 829d96471a

seth wrote:

ssh localhost; w

The same result

❯ ssh au-tokyo-n1.love4taylor.com               
Last login: Mon Oct  2 16:28:45 2023 from ****
love4taylor@au-tokyo-n1 ~ $ ssh localhost
The authenticity of host 'localhost (::1)' can't be established.
ED25519 key fingerprint is SHA256:wbn2T11YRlpI+E9aCZ35IUesVmgIREHyhq7VhYICNPQ.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'localhost' (ED25519) to the list of known hosts.
love4taylor@localhost's password: 
Last login: Tue Oct  3 04:22:01 2023 from ****
love4taylor@au-tokyo-n1 ~ $ w
 04:22:14 up 16:53,  2 users,  load average: 0.03, 0.01, 0.00
USER     TTY       LOGIN@   IDLE   JCPU   PCPU  WHAT
love4tay           04:22   16:52m  0.00s  0.05s sshd: love4taylor [priv]
love4tay           04:22   16:52m  0.00s  0.01s sshd: love4taylor [priv]
love4taylor@au-tokyo-n1 ~ $ 
seth wrote:

Edit: what "problem", btw?
Assuming this depends on the client and you'll simply not get the PTS, what problem are you actually trying to solve?

I don't think I'm describing it poorly, my problem is clear, running the w command after I've ssh logged into the arch server doesn't get the TTY(It should show pts/0) and WHAT(It should show what commands the user is running) contents. The same client with the same connection to the Ubuntu server displays correctly.

There have been similar posts, but they didn't work for me. https://bbs.archlinux.org/viewtopic.php?id=237806

Offline

#8 2023-10-03 04:57:41

love4taylor
Member
From: China
Registered: 2023-09-12
Posts: 5
Website

Re: Logging in via ssh, the w command does not show the TTY number

seth wrote:

I get the remote host and process name, ssh

Did you misunderstand? I am running the w command on a remote host not my local host, how can it show the remote host address and ssh processes.

Offline

#9 2023-10-03 05:55:38

Awebb
Member
Registered: 2010-05-06
Posts: 6,334

Re: Logging in via ssh, the w command does not show the TTY number

seth wrote:

sshd is the daemon and you're not supposed to run that - it gets socket-triggered by the sshd.service

No, it isn't anymore on a fresh Arch. Read https://wiki.archlinux.org/title/OpenSS … management.

@topic: Your w output looks normal to me, at least for an Arch setup.

Last edited by Awebb (2023-10-03 06:01:30)

Offline

#10 2023-10-03 06:23:39

seth
Member
Registered: 2012-09-03
Posts: 52,477

Re: Logging in via ssh, the w command does not show the TTY number

"Great"

Awebb wrote:

Your w output looks normal to me,

I do very much see the login pts, process (ssh) and remote host here.

how can it show the remote host address and ssh processes

The client adding it to utmp.
ssh has an option to not allocate a PTS, but that's certainly not default on the arch client so the difference most likely is somewhere in utempter

stat /usr/lib/utempter/utempter

Edit: and just to be sure

ssh -tt localhost

my problem is clear, running the w command after I've ssh logged into the arch server doesn't get the TTY

I get what you're asking, but not why this poses a problem (if you actually need some data there for specific reasons the crutch would then have been to manually utempter it in there)

Last edited by seth (2023-10-03 06:29:33)

Offline

Board footer

Powered by FluxBB