ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How will change SSH Port from Linux Server?

user-image
تم إضافة السؤال من قبل Muhammad Anzar , DevOps/DevSecOps Architect , Confidential
تاريخ النشر: 2015/03/04
moses Okoth
من قبل moses Okoth , Application Developer , OSLABS LTD

Steps to follow

Step1

 

As root, use your favorite text editor (vi) to edit the sshd configuration file.

vi /etc/ssh/sshd_config

 

Step2

 

Edit the line which states 'Port22'. But before doing so, you'll want to read the note below. Choose an appropriate port, also making sure it not currently used on the system.

# What ports, IPs and protocols we listen for  Port50683

Note: The Internet Assigned Numbers Authority (IANA) is responsible for the global coordination of the DNS Root, IP addressing, and other Internet protocol resources. It is good practice to follow their port assignment guidelines. Having said that, port numbers are divided into three ranges: Well Known Ports, Registered Ports, and Dynamic and/or Private Ports. The Well Known Ports are those from  0 through1023 and SHOULD NOT be used. Registered Ports are those from1024 through49151 should also be avoided too. Dynamic and/or Private Ports are those from49152 through65535 and can be used. Though nothing is stopping you from using reserved port numbers, our suggestion may help avoid technical issues with port allocation in the future.

 

Step3

Switch over to the new port by restarting SSH.

/etc/init.d/ssh restart

 

Step4

Verify SSH is listening on the new port by connecting to it. Note how the port number now needs to be declared.

 

ssh -p  50683

 

Mohand ourabah BENABBAS
من قبل Mohand ourabah BENABBAS , Systems engineer , dimensiondata

On  (/etc/ssh/sshd_config)  change  the parameter (Port) value to port number that you want.  

Abdellatif MIFTAHI
من قبل Abdellatif MIFTAHI , Cloud DevOps engineer , 4D

From command line :sed -i 's/^Port .*/Port X/g' /etc/ssh/sshd_configWhere X is the port you want

مستخدم محذوف‎
من قبل مستخدم محذوف‎

By editing the file /etc/ssh/sshd_config

 

 and changing the line that starts with 'Port' if it has a "#" delete that sign. then save after changing the port, and restart the ssh service by doing 'service sshd restart" or "/etc/init.d/ssh restart"

مستخدم محذوف‎
من قبل مستخدم محذوف‎

Salam Muhammad! Make sure to take the backup of configuration file first.1- sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.orig2-  sudo vi /etc/ssh/sshd_config and update your configuration file.

"port=22"  -> port="new port"3-     Make sure to update firewall before restarting sshd service. (if this is your remote service and is hosted else you wont be able to connect if it is your local server then no worries).4- sudo   cp /etc/apf/conf.apf /etc/apf/conf.apf.orig5- sudo vi /etc/apf/conf.apf **update ingress inbound tcp table to reflect new changes.6- sudo service sshd restartP.S: Make sure NOT to use ports that are already in use by another service/application. use PUTTY to connect to server with updated port.

Rajesh Pant
من قبل Rajesh Pant , System Engineer , Tech Mahindra Limited

Go through below steps to change SSH Port configuration  :1.) Open ssh configuration file for the editing# vi /etc/ssh/sshd_config2.) Append / Edit below mentioned line as per required portPort40223.) Reload the SSH service# service sshd reload (OR #/etc/init.d/sshd reload)4.) check / verify it by using telnet and ssh login on configured port#telnet localhost4022 (OR #telnet serveripaddress4022)OR# ssh -p4022 username@serveripaddress(Note : If you have running IPTABLES & SELINUX security than bypass same port and update configuration changes accordingly)

Syed Javed
من قبل Syed Javed , it consultant , Infosys

Agree to my fellows here... you can change it from sshd_config file

Roshan Firozkhan
من قبل Roshan Firozkhan , IT System Administrator , Emirates Driving Institute

vi /etc/ssh/sshd_config

 

look for line 

port22

 

change the port number and wq!

 

 

 

 

المزيد من الأسئلة المماثلة