SSH (Secure Shell)

“The SSH protocol (also referred to as Secure Shell) is a method for secure remote login from one computer to another. It provides several alternative options for strong authentication, and it protects the communications security and integrity with strong encryption. It is a secure alternative to the non-protected login protocols (such as telnet, rlogin) and insecure file transfer methods (such as FTP).”

Reference:

Adding SSH

Why add ssh. You can open a terminal from your Windows host computer to your virtual Linux computer which allows you to copy paste data. You can also connect from any other computer in the network.

Tested on

References

Pre Requirements

Steps

  1. Install SSH. Install OpenSSH Server Software Package
     $ sudo yum –y install openssh-server openssh-clients
    
  2. Set the service to start with the machine:
     chkconfig sshd on
    
  3. Start the service:
     service sshd start
    

    or

    Starting SSH Service

     $ sudo systemctl start sshd
    
  4. Make sure port 22 is opened:
     netstat –tulpn | grep :22
    
  5. If port 22 is not open, edit /etc/sysconfig/iptables, as before:
     vi /etc/sysconfig/iptables
    

    Add the line:

     -A -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    

    Save and close the file. Restart iptables:

     sudo service iptables restart
    
  6. Check sshd status
     $ sudo systemctl status sshd
    
  7. Optionally, reboot the system. SSH should begin when the system starts.
     sudo reboot
    
  8. Get ip address to connect to via:
    $ ip a
    

TODO: add image of what ip address looks like

Connecting via SSH

To connect via ssh, on a client computer open a terminal with ssh installed and run.

Tested on

References

Pre Requirements

Steps

  1. To connect to your Virtual Machine from your windows local computer you need to know the ip address of your machine. Get ip address of the remote computer (possibly CentOS) you wish to connect to. On the remote computer (possibly CentOS), to view ip address info, run the following.
     $ ip a
    

    The output will look like this: Running on the CentOS VM:

     [root@centos6 ~]# [root@centos6 ~]# ip a
     1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
         link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
         inet 127.0.0.1/8 scope host lo
         inet6 ::1/128 scope host
         valid_lft forever preferred_lft forever
     2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
         link/ether 08:00:27:86:2d:0d brd ff:ff:ff:ff:ff:ff
         inet 10.0.0.166/24 brd 10.0.0.255 scope global eth0
         inet6 2601:140:8700:5550:a00:27ff:fe86:2d0d/64 scope global dynamic
         valid_lft 181697sec preferred_lft 181697sec
         inet6 fe80::a00:27ff:fe86:2d0d/64 scope link
         valid_lft forever preferred_lft forever
     [root@centos6 ~]#
    

    Above the ip address of the computer for ssh is: inet 10.0.0.166 which is found under eth0.

  2. On the local computer (posibly windows) you wish to connect to from open a terminal that has ssh capabilities such as command prompt.
     > ssh <userame>@<ip-address>
    

    Demo:

     $ ssh root@10.0.0.166
    

    This will open a remote session terminal of your VM. With this terminal you can copy and paste text between your Linux VM and you Windows host computer.

Other relevant sections

Enabling SSH enables SCP (secure copy) for secure file transfers.

Journal