LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-28-2023, 10:01 AM   #1
Jason.nix
Member
 
Registered: Feb 2023
Posts: 569

Rep: Reputation: 10
Post Default behavior of SSH


Hello,
In a server with multiple NICs and multiple IP addresses, the SSH service is running by default on all IP addresses? It means that you can connect to all IP addresses through SSH.

Thank you.
 
Old 12-28-2023, 10:32 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,160

Rep: Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266
sudo grep ListenAddress /etc/ssh/sshd_config
 
Old 12-28-2023, 10:32 AM   #3
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Short answer: Yes ... but don't count on it.

Longer answer:

It depends on how it is set up to install by the package maintainer.

Typically, you can examine the file /etc/ssh/sshd_config to see how it is set up. I wouldn't make any assumptions about its default configuration, but rather I'd examine the contents of sshd_config and alter as desired.

So, for example, this is how part of sshd_config might look:

Code:
# 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.

Include /etc/ssh/sshd_config.d/*.conf

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
In this example (from Debian Stable), the commented options represent the defaults, and this includes listening on port 22 and allow listening on any address, from any address.
 
1 members found this post helpful.
Old 12-28-2023, 01:24 PM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,369
Blog Entries: 3

Rep: Reputation: 3771Reputation: 3771Reputation: 3771Reputation: 3771Reputation: 3771Reputation: 3771Reputation: 3771Reputation: 3771Reputation: 3771Reputation: 3771Reputation: 3771
As mentioned twice above, the ListenAddress directive in /etc/ssh/sshd_config will allow you to choose which addresses and thus network interface.

You can add additional conditions to that using the Match directive. So you could allow keys or passwords on the LAN but require keys for access from the Internet.
 
Old 12-30-2023, 12:39 AM   #5
Jason.nix
Member
 
Registered: Feb 2023
Posts: 569

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by smallpond View Post
sudo grep ListenAddress /etc/ssh/sshd_config
Hello,
Thank you so much for your reply.
The output is:
Code:
# grep ListenAddress /etc/ssh/sshd_config
#ListenAddress 0.0.0.0
#ListenAddress ::
 
Old 12-30-2023, 12:42 AM   #6
Jason.nix
Member
 
Registered: Feb 2023
Posts: 569

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by IsaacKuo View Post
Short answer: Yes ... but don't count on it.

Longer answer:

It depends on how it is set up to install by the package maintainer.

Typically, you can examine the file /etc/ssh/sshd_config to see how it is set up. I wouldn't make any assumptions about its default configuration, but rather I'd examine the contents of sshd_config and alter as desired.

So, for example, this is how part of sshd_config might look:

Code:
# 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.

Include /etc/ssh/sshd_config.d/*.conf

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
In this example (from Debian Stable), the commented options represent the defaults, and this includes listening on port 22 and allow listening on any address, from any address.
Hello,
Thank you so much for your reply.
So, I can substitute the desired IP address instead of 0.0.0.0. Is it right?
 
Old 12-30-2023, 01:29 AM   #7
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,474
Blog Entries: 7

Rep: Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573
Yes, that is correct.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Strangle lilo behavior when adding new grub-default distro svar Linux - General 6 06-29-2008 10:03 AM
How do you change default emacs behavior on .h files? BrianK Programming 4 02-26-2008 07:11 PM
ipblock default behavior FolkTheory Linux - Security 3 12-01-2007 12:30 PM
default behavior for Konsole and other x-type terminals muttdawg Slackware 5 09-02-2007 05:31 PM
Change default ls behavior bgfay Linux - Newbie 5 06-21-2004 09:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration