Tuesday, February 16, 2016

ssh - common usage

Hi,

As I put the title of this post, I give simple examples to use it.

What is ssh:
 - ssh is the software utility to connect to remote host/machine(directly to the shell).
 - it supports when there is a 'sshd' service running in the remote machine only.
 - ssh is having so many methodologies to allow most of the clients based on some secure logging techniques.
 - Mostly we use ssh key pair(RSA)  to login to host.
 - SSH is used widely to secure the server from unknown logins even though a person knows the username/password to login.
 - with the help of keypair we use to secure the login.

Simple usage:
 - Generate key pair with below command using any ssh client.

 command: $ssh-keygen -t rsa -C "Some Name"

and while generating we can give password for shell login as an additional security if we want.

Process:
- Usually ssh-keygen generates a key pair (1-public key, 2-private key)
- We don't share the private key and we keep it with us in our machine.
- We will place the public key in the remote host (~/.ssh/authorized_keys).
- While logging to the host ssh client interacts with sshd server and verifies that this ssh client is valid or not based on these key pair match.
- If key pair is matched then only the sshd allows us to login to host.




nano - A simple text editor like vi

Hi,

For people who feel that 'vi' is hard to work then switch to 'nano'.

Like 'vi/vim' this 'nano' also there in almost all linux flavors.

I use it for simple text editing like correcting a word/line in a text file.

Below is the sample screen.

command: $nano


The above screen is having nothing in it, Its actually a fresh editor. We can type something you want and no need to remember any command like 'vi'(esc...i,..etc). Almost all commands it shows on the screen and there is no confusion also.


I usually two of them for regular usage
1) storing - ctrl+o --> Enter
2) closing - ctrl+x

That's all...

If you have interest to know more then take commands helps displaying on the screen.

Usage of 'ps' and 'kill' command in linux

Hi,

Here I have tip on processes.

suppose if I want to see list of currently running processes then we have a system command as 'ps'.

With this we can see list of processes as below if we use additional arguments.

command: $ps -ef




In the same way we have a scenario like, I want to see is there any java process running in my machine.

For this we have to filter above list of processes using additional pipe with grep,

command: $ps -ef | grep java



In this way we can easily find out whether any background service or any process running in the background.


Additional:
---------------

If we want to kill the above process then use 'kill' command with additional argument of 9.

command: $kill -9 7302

The above will invoke the system call kill on that process and the process will be killed in milliseconds.