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
- CentOS 8 64 bit
- CentOS 7 64 bit
- CentOS 7 32 bit
- CentOS 6 32 bit
References
- Add just ssh: broadcom: how-to-enable-ssh-access-to-centos-6
- Complete with connecting internet: extr3metech: configuring-network-in-centos-6-3-virtual-box-screenshots
- phoenixnap: how-to-enable-ssh-centos-7
Pre Requirements
- In network adapter settings, choose Host only or bridge adapter. DONT CHOOSE: NAT
Steps
- Install SSH. Install OpenSSH Server Software Package
$ sudo yum –y install openssh-server openssh-clients
- Set the service to start with the machine:
chkconfig sshd on
- Start the service:
service sshd start
or
Starting SSH Service
$ sudo systemctl start sshd
- Make sure port 22 is opened:
netstat –tulpn | grep :22
- 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
- Check sshd status
$ sudo systemctl status sshd
- Optionally, reboot the system. SSH should begin when the system starts.
sudo reboot
- 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
- CentOS 8 64 bit
- CentOS 7 64 bit
- CentOS 7 32 bit
- CentOS 6 32 bit
References
Pre Requirements
- Connect
local
computer to internet - Setup SSH on
local
computer
Steps
- 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 viewip
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. - On the
local computer
(posibly windows) you wish to connect to from open a terminal that has ssh capabilities such ascommand 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
- 2020.06.10 Created file
- Created
Adding SSH
section - Created
Connecting via SSH
section - Created
Copy Files via SCP
section
- Created
- 2020.06.25 Removed SCP info and added link to relevant sections