Practical Examples

These ssh examples, tips and commands are intended to give you a starting point

Connecting to a remote SSH server

                    
                        
                    
                

-v : Print debug information
-p 22 : Specify which port to connect to on the remote SSH server
user@ : The string before the @symbol denotes the username to authenticate with against the remote server.
remoteserver : The hostname ssh

Change the SSH Port

Commands valid for CentOS

In CentOS the default firewall management tool is FirewallD. To open the new door, run the following commands:

                    
                        
                    
                
                    
                        
                    
                

Open the SSH configuration file with your text editor

/etc/ssh/sshd_config

                    
                        
                    
                

Look for the line that starts with Port 22. In most cases, this line will start with a hash #.Remove the hash # and enter your new SSH port number which will be used in place of the standard SSH port 22, like so:

                    
                        
                    
                

Be especially careful when editing the SSH configuration file. An incorrect configuration could prevent the SSH service from starting.

Save and close the file by pressing CTRL + X, followed by Y to save the changes and then ENTER if you are using nano.

Once finished, save the file and restart the SSH service to apply the changes:

                    
                        
                    
                

Use the new SSH port

                    
                        
                    
                

Close the port 22

                    
                        
                    
                

Firewall reload