Friday, May 31, 2013

connect to the server using ssh

Log into the server using ssh

To connect to the server using ssh, ssh daemon (ssh server) should be installed on the server and ssh client should be installed on the client (from where you are connecting to the server)
For installation process, click here

Steps
Open terminal on the client and run following command.
$ ssh username@xxx.xxx.xx.xx
where xxx.xx.xx.xx is IP address of the server/.
Example - $ ssh root@192.168.2.7 

It asks for server's root password. Now enter server's password and press return key, you have logged into the server's root account.

if you run 
$ ssh root@192.168.2.7  or $ ssh 192.168.2.7
both are same thing. To log in to root's account, you do not need to mention root as a username. Username is necessary if you log into any user's account.

Suppose you want to log into John's account, Run
$ ssh john@192.168.2.7
where john is username &
192.168.2.7 is IP of the server

It asks for john's password. After submit password, you log into john's account.

Install ssh on Ubuntu/Debian


ssh (secure shell)
         ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine.  It is intended to replace rlogin and rsh, and provide secure encrypted communications between two untrusted hosts over an insecure network.  X11 connections and arbitrary TCP ports can also be forwarded over the secure channel.

  ssh connects and logs into the specified hostname (with optional user name).  The user must prove his/her identity to the remote machine using one of several methods depending on the protocol version used (see below).


Install ssh on Ubuntu/Debian

Run following command in terminal
# apt-get install openssh-server openssh-client

Start and stop the ssh service
# service ssh start & # service ssh stop

Automatically start the service at boot
# chkconfig ssh on

Check status of ssh
# service ssh status

Check port 22 is opened or not
Run following command
# netstat -tulnp | grep :22

Output should be like this
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 9657/sshd tcp 0 0 :::22 :::* LISTEN 9657/sshd

Install ssh on CentPS/RHEL/Fedora
click here

Install ssh on Linux - CentOS/Fedora/RHEL/SL


ssh (secure shell)
         ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine.  It is intended to replace rlogin and rsh, and provide secure encrypted communications between two untrusted hosts over an insecure network.  X11 connections and arbitrary TCP ports can also be forwarded over the secure channel.

  ssh connects and logs into the specified hostname (with optional user name).  The user must prove his/her identity to the remote machine using one of several methods depending on the protocol version used (see below).

sshd (secure shell daemon) - ssh server

Install ssh on CentOS/Fedora/RHEL/Scientific Linux

Run following command in terminal
# yum install openssh-server openssh-clients

Start and stop the ssh service
# service sshd start & # service sshd stop

Automatically start the service at boot
# chkconfig sshd on

Check status of ssh
# service sshd status

Firewall :
Open Port 22 in Firewall :
Add following line in the file /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

Restart iptables
# service iptables restart

Check port 22 is opened or not
Run following command
# netstat -lnp | grep :22

Output should be like this
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 9657/sshd tcp 0 0 :::22 :::* LISTEN 9657/sshd

Install ssh on Debian/Ubuntu
click here