Virtualbox (NAT mode) implements SSH

Source: Internet
Author: User
Tags openssh server ssh port

Source: http://www.linuxidc.com/Linux/2012-02/53989.htm

Host OS: Windows 7

Guest OS: centos 5.7

Virtual Machine: virtualbox 4.1.2

Connection Type: Nat

--------------------------------------------------------------------

It is just a simple implementation. Other refined things are re-extended and support for open-source software. The implementation is as follows:

Go to guestos:

#/Sbin/ifconfig

View Inet ADDR: 10.0.2.15

Then go to the Hostos to check the control panel and the virtualbox host-only network in the network and sharing center.

IP address of the IPv4 attribute: 192.168.56.1

If you have prepared enough, configure it as follows:

Tip: the default ssh port is 22.

Open the virtualbox settings window> network> adapter1 enable network connection> connection mode: Nat> access network cable>

Port forwarding:

Map the TCP 192.168.56.1: 2222 to 10.0.2.15: 22.

OK. Restart and enable putty.

Session-> Host Name (or IP address) 192.168.56.1; port: 2222-> open

-> Login successful.

Openssh-client and openssh-Server
If you only want to log on to another machine for SSH, you only need to install OpenSSH-client (Ubuntu has a default installation, if not, sudo apt-Get install OpenSSH-client ), to enable the SSH service on the local machine, install OpenSSH-server.
Sudo apt-Get install OpenSSH-Server
Then confirm whether the sshserver is started:
PS-E | grep SSH
If you see sshd, it indicates that the ssh-server has been started.
If not, start sudo/etc/init. d/ssh start as follows:
The SSH-server configuration file is located in/etc/ssh/sshd_config. Here, you can define the SSH service port. The default port is 22. You can define other port numbers, such as 222.
Then restart the SSH service:
Sudo/etc/init. d/ssh stop
Sudo/etc/init. d/ssh start
Then use the following method to log on to SSH:
The SSH tuns@192.168.0.100 Tuns is the user on the 192.168.0.100 machine and requires a password.
Disconnect: Exit

If you have installed the SSH service but do not want it to start automatically at startup, you can set it as follows: in/etc/init/ssh. conf, find

Start on filesystem or runlevel [2345]

Comment out a line. The result is as follows:

Click (here) to fold or open

# Ssh-OpenBSD Secure Shell Server

#

# The OpenSSH server provides Secure Shell access to the system.

Description "OpenSSH server"

# Start on filesystem or runlevel [2345]

Stop on runlevel [! 2345]

If you have installed the SSH service but do not want it to start automatically at startup, you can set it as follows: in/etc/init/ssh. conf, find

Start on filesystem or runlevel [2345]

Comment out a line. The result is as follows:

Click (here) to fold or open

# Ssh-OpenBSD Secure Shell Server

#

# The OpenSSH server provides Secure Shell access to the system.

Description "OpenSSH server"

# Start on filesystem or runlevel [2345]

Stop on runlevel [! 2345]

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.