SSH β A View
SSH, also known as Secure Shell or Secure Socket Shell, is aΒ network protocolΒ that gives users, particularly system administrators, a secure way to access a computer over an unsecured network.
By default SSH is installed in linux.We can check the version by using this below command.
ssh -V
Otherwise we can install it by..,
sudo apt install openssh-server openssh-client
sudo systemctl status ssh
Also we can check the status of SSH.The default Port Number assigned by ssh is 22.We can change it in the configuration file also we can allow or deny users or groups and Alive Interval in the configuration file.
NOTE :
Restart the ssh after configured.
nano /etc/ssh/sshd_config
AllowUsers user_name
AllowGroups group_name
To allow permissions to specific users and groups to access ssh.
DenyUsers user_name
DenyGroups group_name
To deny the permission to specific users and groups.
LoginGraceTime specify_time
(i.e) 1m ==> 1 minute.
If a user canβt make a successful login with the specific time,it will not allow the user to enter into the remote machine.
ClientAliveInterval 600
ClientAliveCountMax 0 ==> Default it is zero.
(i.e) 600 ==> 600 seconds = 10 minutes.
The tunnel will break after the mentioned time (600 seconds) if there is no actions were performed by the user in the server.
NOTE: Restart the service once changes are made in configuration file.
ssh user_name@remote_ip
ssh user_name@remote_hostname -p port_number
To connect to the ssh server we must need three credentials of the remote machine.
- Username.
- Password.
- Ip Address or Hostname.
scp file_to_transfer user_name@hostname:/path_to_copy_the_file_in_remote_server
scp -P specific_port_number file_to_transfer user_name@hostname:/path_to_copy_the_file_in_remote_server ===> For using Port Number other than 22.
Example : scp hello.go student@ip_address:/home/student/Checking_scp_command/
scp -P 2027 hello.go student@ip_address:/home/student/Checking_scp_command/
SCP ==> Secure Copy.
To copy a file securely to the remote serverβs directory named βChecking_scp_commandβ.
scp user_name@hostname:/path_of_the_file/file /path_to_copy_in_local_system
scp -P specific_port_number user_name@hostname:/path_of_the_file/file /path_to_copy_in_local_system ===> For using Port Number other than 22.
Example : scp student@ip_address:/home/student/Checking_scp_command/Remote_to_Local.txt /home/g/Downloads/
scp -P 2027 student@ip_address:/home/student/Checking_scp_command/Remote_to_Local.txt /home/g/Downloads/
In this command,we are going to get the file from remote server to our local system.
NOTE:
There is a command called βssh-keygenβ which generates a unique key for accessing the remote server via local system.
This never ask passwords to enter into the system,But be careful of handling this key.If you are not familiar with this method,just practice with the password type few times.
Keygen will be discussed later in our next post.Stay tunedβ¦
Thatβs it..!