Score:-3

changing the sshd port to 2222 still accept only port 22 ubuntu 23.04

mc flag

i change the port in /etc/ssh/sshd_config to Port 2222 enter image description here but when i try to login ssh -p 2222 myuser@hostname_ip it gives me : enter image description here

but when i try with port 22 all working i did restart the vm after change . what im missing here ?

Romeo Ninov avatar
in flag
1. Add in question text, not images. 2. DId you restart `sshd` after editing the config?
user61104 avatar
mc flag
yes did restart
alexus avatar
sa flag
restart `sshd` and provide `netstat` output)
Score:3
ar flag

In short, sshd is controlled by Systemd. This is outlined in the comment in the three lines above your Port statement. Reading comments in config files is usually useful, especially when things don't work the way you expect.

If you read the suggested file, it will contain the following snippet:

The provided ssh.socket unit file sets ListenStream=22.  If you need to have
it listen on a different address or port, then you will need to do this as
follows (modifying ListenStream to match your requirements):

  mkdir -p /etc/systemd/system/ssh.socket.d
  cat >/etc/systemd/system/ssh.socket.d/listen.conf <<EOF
  [Socket]
  ListenStream=2222
  EOF
  systemctl daemon-reload

See systemd.socket(5) for details.

I would perhaps suggest doing that. I would also strongly suggest actually reading documentation.

user61104 avatar
mc flag
i have something strange at work i have this problem , at home same laptop all working fine with port 22 the defualt
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.