Linux-enabled SSH (CentOS) in VirtualBox

Source: Internet
Author: User

Reprint: http://www.linuxidc.com/Linux/2015-02/113625.htm

The first time I use SSH to connect Linux on VirtualBox, I'm going to buy a cloud space to use it, so get a CentOS practiced hand first. Because it is the virtual machine on the SSH connection when the time wasted a little trouble, hereby record. My choice is CentOS6.4, mainly includes the following and steps:

1. Switch the network mode of the virtual machine.
2. Set the SSHD service to start from.
3. Start the sshd service.
4, connect via putty.
5, problems encountered in the process.

Because SSH and virtual machine share a machine, so the installation of CentOS after a moment to touch the connection of the IP should be what. Since VirtualBox is NAT (Network address translation) By default, it is not possible to connect to the virtual machine by ipconfig seeing the IP of the virtual network card on the host machine (as if it were to modify the forwarding rules of the VirtualBox, which is tried later). Finally, by modifying the network connection mode bit bridging (bridge Adapter) way, the network card address directly to the CentOS use.
To modify the steps: Turn off the virtual machine, select the virtual machine in the administration interface---set-up network:


After Setup, you can view the current IP address at the CentOS terminal, Ifconfig:


At this point 1 to finish the call, the next set up the sshd service for self-boot, so that it does not have to run after each boot to the virtual machine that end boot once.
Use command: Chkconfig sshd on set to boot
Use the command: Chkconfig--list |grep sshd to view the settings results, note that this requires root permission to set. As follows:

Guess what the 0~6 in the list should represent is the Linux operating mode.

Next 3 start sshd, this is nothing to say the default 22 port, the direct use of the command: Service sshd start.

And then 4 through the SSH tool, here is the Putty connection. In CentOS, the Iptables policy is accept by default, so it does not need to be set up, if it is other system may involve firewall release introduced in 5.

5 Problems encountered:
The biggest problem is the virtual machine in the IP can not find, do a lot of attempts and Google, once stopped the NetFilter component (ie, iptables).
Second, although the iptables rule in CentOS is accept by default, the actual scenario is much safer to choose drop in input and output. This is an urgent need to add a command to develop Port 22:
Iptables-a input-p tcp-m tcp-sport 22-j ACCEPT
Iptables-a output-p tcp-m tcp-dport 22-j ACCEPT

--------------------------------------------------------
Add a PostScript:
Try a bit of the original do not need to switch network mode, direct NAT can. Find an introduction to the network from the VirtualBox help, where the NAT pattern is similar to the physical router of the home, but this time the router is the VirtualBox routing engine, it separated the virtual machine from the outside world, only need to set the lower port forwarding to complete the purpose of connecting to the development of the virtual machine port , the end result is that all the messages sent to the VirtualBox IP designated port are forwarded to the corresponding port, where 22 is required. Settings are as follows:
1. Set the network to NAT and add port forwarding rules after shutting down the virtual machine:

2, directly connected to the VirtualBox of the corresponding port of the virtual network card, through the host machine Ipconfig can be viewed to my VirtualBox current IP: [email protected]:

3, finish the call. Connection is normal.

The way to improve the speed of SSH login authentication in Ubuntu http://www.linuxidc.com/Linux/2014-09/106810.htm

Enable the SSH service to allow Android phones to access Ubuntu 14.04 http://www.linuxidc.com/Linux/2014-09/106809.htm remotely

How to add two-factor authentication to SSH in a Linux system http://www.linuxidc.com/Linux/2014-08/105998.htm

Configuring the SFTP Environment for non-SSH users in Linux http://www.linuxidc.com/Linux/2014-08/105865.htm

Configuration and management of SSH services on Linux http://www.linuxidc.com/Linux/2014-06/103627.htm

Basic tutorial for getting started with SSH http://www.linuxidc.com/Linux/2014-06/103008.htm

Linux-enabled SSH (CentOS) in VirtualBox

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.