Monday, December 1, 2014

ssh config

Leave a Comment

what is ssh? 

SSH is a protocol to log-in remote server. it's the most common way to access remote server in linux system and linux commands is useful in linux system, in this articles, how to ssh config?


ssh remote_username@remote_host 
ssh config

  • remote_username: user of server you wish remote access.
  • remote_host: ip address or domain name of remote access the server.

how does ssh work?

SSH works by a client program which it's connecting to an ssh server. Client-side as command above and server-side  service sshd server already running.

Basic of ssh config

SSH config the store in /etc/ssh/sshd_config file.
vi /etc/ssh/sshd_config

Disable or enable root log-in

PermitRootLogin yes
if you allow root access thought ssh use as command above, contrary.

Change port ssh

Default ssh port 22, you can change port non-standard.
Port 8888
Note: you check firewall in centos actually open . if firewall not open port 8888 you open port 8888 as command line bellow:
 firewall-cmd --zone=public --query-port=8888/tcp

Open the port 8888 in firewall using command line as bellow:
firewall-cmd --zone=public --add-port=8888/tcp --permanent
Restart ssh config:
systemctl reload sshd.service
you can via linux firewall to more detail:

Other configuration 

# Authentication:
LoginGraceTime 2m
StrictModes yes
MaxAuthTries 6
MaxSessions 10 

How to login ssh use keys

Log-in ssh use keys a better idea for secure to access remote server. Key-base authentication works by creating a pair of keys:

  • Private key: the located on the client
  • Public key: the located on server you wish access and for anyone.

How to create SSH keys

Enter the following into the command line and press enter by default:
ssh-keygen -t rsa

The command above create 2 file in hidden ~/.ssh folder :  ~/.ssh/ and ~/.ssh/id_rsa.

Change to ssh directory use cd command as bellow:
cd ~/.ssh 
ls -l

How to transfer public key to the server

ssh-copy-id remote_host
I hope will this help you!
Copyright by:


Post a Comment