[LINUX] Connect to centos6 on virtualbox with ssh connection from Mac


Guest OS: CentOS6 Host OS: MacOS Catalina


① Open the network with virtualbox settings

・ Set below. Allocation: Host-only adapter ・ Confirmation of name Name: vboxnet0 スクリーンショット 2020-01-16 17.48.26.png

② Start centos

③ Check the network on centos

Check the network with ʻip a` on centos. In the case of my setting, I confirmed that eth2 was added by the setting of ①, but the IP address was not set in eth2. It is unknown why it was eth2 instead of eth1. ..

> ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet brd scope global eth0
    inet6 fe80::a00:27ff:fe84:eb71/64 scope link 
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
↑ No IP address listed

④ Set the IP address in eth2.

Set manually. (1) Add the configuration file for eth2 under / etc / sysconfig / network-scripts /. I have / etc / sysconfig / network-scripts / ifcfg-eth0 but not / etc / sysconfig / network-scripts / ifcfg-eth2, so I copied the ifcfg-eth0 file.

> cd /etc/sysconfig/network-scripts/
> ls
ifcfg-eth0      ifdown-ippp    ifup-aliases    ifup-ppp
ifdown-ipv6     ifup-bnep      ifup-routes     ifdown-isdn
ifup-eth        ifup-sit       ifdown-post     ifup-ippp
ifup-tunnel     ifdown-ppp     ifup-ipv6       ifup-wireless
ifcfg-lo        ifdown-routes  ifup-isdn       init.ipv6-global
ifdown          ifdown-sit     ifup-plip       net.hotplug
ifdown-bnep     ifdown-tunnel  ifup-plusb      network-functions
ifdown-eth      ifup           ifup-post       network-functions-ipv6
↑ ifcfg-There is no eth2 file.

> cp ifcfg-eth0 ifcfg-eth2

⑵ Check the network status of mac. Check the network address of the name (vboxnet0) set in the virtualbox network with ifconfig from the terminal. Derived from the IP address and subnet mask. If the IP address is, will be the network address.

(3) Change the ifcfg-eth2 file that you copied earlier to the correct contents. As it is, it is exactly the same as the ifcfg-eth0 file!

Change before


↓ Change to the following

After change

# HWADDR=************ Comment out
# UUID=************ Comment out
BOOTPROTO=none ← changed from dhcp
IPADDR= ← added
PREFIX=24 ← added

・ DEVICE is specified as eth2 (Here, eth2 was newly added in ʻip a earlier, so match it) If eth1 etc. is output by ʻip a, enter the output device name -Change BOOTPROTO from dhcp to none so that the IP address is not automatically assigned. -Add an address that can be assigned to the network address confirmed in (2) to IPADDR. Since I was using on my mac, I set it to PREFIX is set to the same value as confirmed in ⑵.

⑤ Restart the network and complete the connection from the terminal!


service network restart


ssh [email protected]

About this setting

・ About host-only adapter I increased the NIC by adding a host-only adapter in virualbox. The host-only adapter is set to connect only the host OS (MacOS) and guest OS (CentOS6), and cannot be connected to the outside. ・ This connection method The NIC on the host OS side ( in this example) and the NIC on the guest OS side ( in this example) were connected.

Recommended Posts

Connect to centos6 on virtualbox with ssh connection from Mac
Steps to install VirtualBox on CentOS
Install VirtualBox on CentOS 7 on VirtualBox (mac + vagrant)
Ssh connect to GCP from Windows
Update Python on Mac from 2 to 3
[Cyberduck] How to exchange files on Linux (CentOS7) started by VirtualBox with mac using GUI
Connect to Packetix VPN from CentOS 7 minimal.
Until SSH connection with Fabric (MacOS-> CentOS7)
Connecting from python to MySQL on CentOS 6.4
To connect to WIFI that is restricted by MAC address with CentOS (NetworkManager).
[Note] ssh connection from terminal with AWS LightSail
Boot CentOS 8 from Windows 10 with Wake On LAN
Connect to MySQL with Python on Raspberry Pi
Use Tor to connect from urllib2 [Python] [Mac]
Installation on CentOS8 VirtualBox
Preferences to generate animated GIFs from Python on Mac
I want to AWS Lambda with Python on Mac!
How to set a shared folder with the host OS in CentOS7 on VirtualBOX
From installing Flask on CentOS to making it a service with Nginx and uWSGI
Two ways to SSH into CentOS on an Azure VM with Azure AD user credentials
Connect to BigQuery with Python
[CentOS 7.7] From desktop environment installation to remote desktop connection possible (from minimum installation)
How to install Python2.7 python3.5 with pyenv (on RHEL5 CentOS5) (2016 Nov)
SSH connection to a private server using a bastion server on EC2
Connect to Wikipedia with Python
[Postgresql] SSH connection to the external DB server from the client
Connect to Postgresql with GO
Update python on Mac to 3.7-> 3.8
How to connect to Cloud SQL PostgreSQL on Google Cloud Platform from a local environment with Java
Switch from python2.7 to python3.6 (centos7)
Connect to sqlite from python
How to install Theano on Mac OS X with homebrew
Use ssh with private key public key authentication. Connect from wan.
How to rebuild python environment from pyenv on Mac environment (El Capitan)
How to run Jupyter and Spark on Mac with minimal settings
How to connect to Cloud Firestore from Google Cloud Functions with python code
I tried to display GUI on Mac with X Window System
From PyCUDA environment construction to GPGPU programming on Mac (MacOS 10.12 Sierra)
Steps to install MySQL 8.0 on CentOS 8.1
tensor flow with anaconda on mac
Connect to multiple databases with SQLAlchemy
How to install mysql-connector-python on mac
Create folders from '01' to '12' with python
Convert wma to mp3 on Mac
Introducing OpenCV on Mac with homebrew
[Linux] I installed CentOS on VirtualBox
How to install OpenCV on Mac
How to install PyPy on CentOS
Connect to utf8mb4 database from python
Misunderstanding on how to connect cnn
How to install TensorFlow on CentOS 7
Connect to Bitcoin Testnet with Pycoin
Connect to Elastic MQ with boto
How to install Maven on CentOS
Steps to install python3 on mac
Call C / C ++ from Python on Mac
Connect to VPN with your smartphone and turn off / on the server
How to use gcc when compiling extension modules from setup.py on Mac
Data integration from Python app on Linux to Amazon Redshift with ODBC
Edit the file of the SSH connection destination server on the server with VS Code
Links for handling jupyter notebooks on Docker on Ubuntu on VirtualBox on macOS with SSH