Can't access ssh in my VM Centos

47,322

Solution 1

Depends on how you configured your network interfaces. I would check in /etc/sysconfig/network-scripts/ifcfg-eth0 on the new VM and see if you can just change the value for IPADDR if it's present. If you have NetworkManager running and the interface is configured with NM_CONTROLLED=yes then the change will be applied when you save the file, otherwise you'll have to do a service network restart to make the change effective.

Solution 2

This looks like you're using VirtualBox VM with a NAT network (it seems to give the address 10.0.2.15 by default). If so, you need to set up a port forward to access port 22 on the VM from the host.

  1. Open Settings->Network for the VM
  2. Click the little blue arrow next to the Advanced box
  3. Click the box at the bottom labelled "Port Forwarding"
  4. Click the green "+" to add a rule
  5. Add the rule Host IP="127.0.0.1", Host Port="2222", Guest IP="10.0.2.15", Guest Port="22"
  6. From the host, you should be able to "ssh -p2222 127.0.0.1"

This is a bit stupid compared to the way VMWare does NAT. It creates a separate network interface on the host for NAT, so no forwarding is necessary.

Share:
47,322

Related videos on Youtube

Zobody
Author by

Zobody

Updated on September 18, 2022

Comments

  • Zobody
    Zobody over 1 year

    My Centos's IP is diferent of the normal.

    And I can't access it in a ssh command see here

    And when I tried access using ssh noting see here

    I want to use ssh and samba client, but my IP is diferent.

    And I have install Centos in my other VM in a diferent Ubuntu, but the IP appear the same 10.0.2.15

    How can I fix this problem?

  • Zobody
    Zobody about 10 years
    Ok @Joel Davis, but see my ifcfg-eth0 [link]uploaddeimagens.com.br/imagens/…
  • Bratchley
    Bratchley about 10 years
    You're coming off DHCP, which means it's the DHCP server that is giving the same IP address out, probably because the MAC address didn't change when you cloned. I'd change the MAC at the VirtualBox and RHEL (in that same file) levels and then reboot.
  • Zobody
    Zobody about 10 years
    Right @Joel Davis. But how can I change the MAC at the VirtualBox and RHEL?
  • Bratchley
    Bratchley about 10 years
    Change the MAC Address in the file you showed me to take care of RHEL and in VirtualBox: VirtualBox Main Manager -> guest settings -> networking -> advanced
  • Zobody
    Zobody about 10 years
    ok, but when I do rhis, can I make a ssh and samba client connection?
  • Zobody
    Zobody about 10 years
    when I tried to connect using ssh appear the message "Connection refused" or "No route to host" even than I change the port, noting change. See link uploaddeimagens.com.br/imagens/…
  • dr_
    dr_ over 7 years
    Yes, you can. And this should be the accepted answer. (Commenting for future readers, since OP posted over 2 years ago.)
  • industry7
    industry7 about 7 years
    To back up @dr01, I just used this answer to fix the same issue. I'm using a CentOS 7 guest on a Win7 host.
  • Máster
    Máster almost 6 years
    This worked for me.