[WORK-AROUND] cannot ssh from host to LFS201 CentOS vm
EDIT 4.1.2018
I've just completed my work-around for this issue, and have documented my solution below. It's not ideal, since I'd like to be working with the VM provided for this course, but this gets the job done for me:
- ON HOST - Download the minimal iso from CentOS directly (https://centos.org/download/)
- ON HOST - create a new virual machine in VirtualBox with the iso
- ON HOST - set up network as NAT (default behavior)
- ON HOST - setup port forwarding from Host 2223 to Guest 22
- ON HOST - under Settings > System > Processor, set processors to 2
- ON GUEST - enable networking by editing
and setting/etc/sysconfig/network-scripts/ifcfg-$IFACE_NAME
ONBOOT=yes
- ON GUEST - restart networking via systemctl
- ON GUEST - confirm openssh-server is installed
- ON GUEST - confirm sshd is running
- ON GUEST - confirm ssh to localhost is successful
- ON HOST -
SUCCESSFUL ACCESS OVER SSH!ssh user@127.0.0.1 -p 2223
- ON GUEST - run the ready-for.sh script provided by the Linux Foundation (https://training.linuxfoundation.org/cm/prep/?course=LFS201) to install software and confirm hardware configuration
- Do a little dance
From what I've fonund, the CentOS VM (possibly others as well? haven't tried them yet) is not provided to the students in such a way to allow access over ssh.
-----------------------------------------------------
Hello all! I've been trying to figure this out, and no luck...
My goal is to ssh from my local machine to the CentOS VM provided for LFS201. My local machine is running Ubuntu 17.10, and I'm using Virutalbox Version 5.2.8 r121009 (Qt5.9.1).
Things I've checked on the VM itself:
- sshd is running, confirmed via systemctl and via ssh'ing from the vm itself to localhost (doing `ssh localhost` works just fine)
- firewalld allows ssh, confirmed via `firewalld-cmd --list-services`
- iptables is NOT running
- no mention of an SSH attempt in /var/log/messages or /var/log/secure
-
[student@CentOS7 ~]$ uname -a
Linux CentOS7 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[student@CentOS7 ~]$ cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
Things I've checked on VirtualBox:
- Networking is setup over NAT
- Port forwarding is enabled via `VBoxManage showvminfo lfcs | grep ssh
NIC 1 Rule(0): name = ssh, protocol = tcp, host ip = 127.0.0.1, host port = 2222, guest ip = 10.10.2.15, guest port = 22`
Here's what happens when I try to ssh:
`ssh -p 2222 student@127.0.0.1
ssh_exchange_identification: read: Connection reset by peer`
Any thoughts on what I'm missing?
Thanks,
~Max
Comments
-
Hi,
1.- Just to be sure, are you trying to connect by ssh from the host to the guest, right?
2.- Ssh service is running and accepting connections when you try in the vm itself, is that right?
3.- I see you are trying: ssh -p 2222 student@127.0.0.1 . Are you doing that in the host? If so, in that case you are trying to connect from the host to the host, not the guest. So you need to use the guest's IP, because the host should be able to reach the guest using the associated network.
Regards,
Luis.
0 -
Hey Luis! Thanks for taking a look!
- confirmed, trying to ssh from host to guest
- confirmed, sshd is running in the VM itself and is accepting connections. From inside the VM, executing `ssh localhost` functions correctly (I am prompted for a password, and can authenticate successfully)
- confirmed, I am ssh'ing from host to guest. As I understood it, since I am using VirtualBox with a NAT network, I can't ssh directly to the machine's IP and need to use port forwarding (https://www.virtualbox.org/manual/ch06.html#natforward), but I may have misunderstood.
- I get a Connection timed out error when ssh'ing to the IP, both with and without the port forwarding:
- `➜ ~ ssh -p 2222 student@10.10.2.15
ssh: connect to host 10.10.2.15 port 2222: Connection timed out`
-
`➜ ~ ssh student@10.10.2.15
ssh: connect to host 10.10.2.15 port 22: Connection timed out`
- `➜ ~ ssh -p 2222 student@10.10.2.15
- I get a Connection timed out error when ssh'ing to the IP, both with and without the port forwarding:
0 -
Hi,
If you just need to ssh into the guest, the easiest thing is to setup the network to bridged mode, and that's all. Please tell me if that works for you.
Take a look to Table 6.1. Overview in the VirtualBox user's manual:
https://www.virtualbox.org/manual/ch06.html
Regards,
Luis.
0 -
Hey Luis, thanks for checking in!
I've just completed my work-around for this issue, and have documented my solution below:
- ON HOST - Download the minimal iso from CentOS directly (https://centos.org/download/)
- ON HOST - create a new virual machine in VirtualBox with the iso
- ON HOST - set up network as NAT
- ON HOST - setup port forwarding from Host 2223 to Guest 22
- ON HOST - under Settings > System > Processor, set processors to 2
- ON GUEST - enable networking by editing `/etc/sysconfig/network-scripts/ifcfg-$IFACE_NAME` and setting ONBOOT=yes
- ON GUEST - restart networking via systemctl
- ON GUEST - confirm openssh-server is installed
- ON GUEST - confirm sshd is running
- ON GUEST - confirm ssh to localhost is successful
- ON HOST - ssh user@127.0.0.1 -p 2223
- SUCCESSFUL ACCESS OVER SSH!
- ON GUEST - run the ready-for.sh script provided by the Linux Foundation (https://training.linuxfoundation.org/cm/prep/?course=LFS201) to install software and confirm hardware configuration
From what I've fonund, the CentOS VM (possibly others as well? haven't tried them yet) is not provided to the students in such a way to allow access over ssh.
0 -
SOrry, I still don't understand. ssh to and from the guest works on the CentOS7 VM's we provide in both vmware and virtual box as confirmed by the experience of many. (All guest VMS have been through ready-for.sh for all relevant coruses). The problems you have are purely on the host and the way your firewall etc is set up, probably, as seen by your need to mess with port forwarding. Finally sshing to 127.0.0.1 would nothing as is always the local host but you have used the -p option as a work around. Sometimes people have trouble with the ntewrok setup if the host is on wireless and not wired and/or the host is not connected to network, and changing from bridged to NAT can help.
You have solved a problem with your setup on the host machine, but the workaround is nto necessary. you should be able to use the actual IP address of the guest.
0 -
Hi Maxg!
Well, that sounds like you found a harder way to solve it! Anyway, you got this fixed, so let's dance a bit and keep progressing.
Regards,
Luis.
0
Categories
- All Categories
- 143 LFX Mentorship
- 143 LFX Mentorship: Linux Kernel
- 817 Linux Foundation IT Professional Programs
- 368 Cloud Engineer IT Professional Program
- 167 Advanced Cloud Engineer IT Professional Program
- 83 DevOps Engineer IT Professional Program
- 132 Cloud Native Developer IT Professional Program
- 122 Express Training Courses
- 122 Express Courses - Discussion Forum
- Microlearning - Discussion Forum
- 6.7K Training Courses
- 40 LFC110 Class Forum - Discontinued
- 73 LFC131 Class Forum
- 39 LFD102 Class Forum
- 237 LFD103 Class Forum
- 22 LFD110 Class Forum
- 44 LFD121 Class Forum
- 1 LFD123 Class Forum
- LFD125 Class Forum
- 17 LFD133 Class Forum
- 9 LFD134 Class Forum
- 17 LFD137 Class Forum
- 70 LFD201 Class Forum
- 3 LFD210 Class Forum
- 2 LFD210-CN Class Forum
- 2 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum - Discontinued
- 1 LFD233 Class Forum
- 3 LFD237 Class Forum
- 23 LFD254 Class Forum
- 721 LFD259 Class Forum
- 110 LFD272 Class Forum
- 3 LFD272-JP クラス フォーラム
- 10 LFD273 Class Forum
- 251 LFS101 Class Forum
- 2 LFS111 Class Forum
- 3 LFS112 Class Forum
- 3 LFS116 Class Forum
- 3 LFS118 Class Forum
- 1 LFS120 Class Forum
- 3 LFS142 Class Forum
- 3 LFS144 Class Forum
- 3 LFS145 Class Forum
- 1 LFS146 Class Forum
- 16 LFS148 Class Forum
- 8 LFS151 Class Forum
- 1 LFS157 Class Forum
- 70 LFS158 Class Forum
- LFS158-JP クラス フォーラム
- 5 LFS162 Class Forum
- 1 LFS166 Class Forum
- 3 LFS167 Class Forum
- 1 LFS170 Class Forum
- 1 LFS171 Class Forum
- 2 LFS178 Class Forum
- 2 LFS180 Class Forum
- 2 LFS182 Class Forum
- 4 LFS183 Class Forum
- 30 LFS200 Class Forum
- 737 LFS201 Class Forum - Discontinued
- 2 LFS201-JP クラス フォーラム
- 21 LFS203 Class Forum
- 118 LFS207 Class Forum
- 2 LFS207-DE-Klassenforum
- LFS207-JP クラス フォーラム
- 302 LFS211 Class Forum
- 55 LFS216 Class Forum
- 54 LFS241 Class Forum
- 43 LFS242 Class Forum
- 37 LFS243 Class Forum
- 13 LFS244 Class Forum
- 6 LFS245 Class Forum
- LFS246 Class Forum
- LFS248 Class Forum
- 111 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 145 LFS253 Class Forum
- LFS254 Class Forum
- 2 LFS255 Class Forum
- 13 LFS256 Class Forum
- 1 LFS257 Class Forum
- 1.3K LFS258 Class Forum
- 11 LFS258-JP クラス フォーラム
- 116 LFS260 Class Forum
- 156 LFS261 Class Forum
- 41 LFS262 Class Forum
- 82 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 23 LFS267 Class Forum
- 25 LFS268 Class Forum
- 29 LFS269 Class Forum
- 7 LFS270 Class Forum
- 200 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- 2 LFS147 Class Forum
- LFS274 Class Forum
- 3 LFS281 Class Forum
- 18 LFW111 Class Forum
- 262 LFW211 Class Forum
- 179 LFW212 Class Forum
- 15 SKF100 Class Forum
- SKF200 Class Forum
- 2 SKF201 Class Forum
- 791 Hardware
- 199 Drivers
- 68 I/O Devices
- 37 Monitors
- 98 Multimedia
- 174 Networking
- 91 Printers & Scanners
- 85 Storage
- 754 Linux Distributions
- 82 Debian
- 67 Fedora
- 16 Linux Mint
- 13 Mageia
- 23 openSUSE
- 149 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 351 Ubuntu
- 465 Linux System Administration
- 39 Cloud Computing
- 71 Command Line/Scripting
- Github systems admin projects
- 95 Linux Security
- 78 Network Management
- 101 System Management
- 47 Web Management
- 56 Mobile Computing
- 18 Android
- 28 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 366 Off Topic
- 114 Introductions
- 171 Small Talk
- 26 Study Material
- 534 Programming and Development
- 304 Kernel Development
- 223 Software Development
- 1.8K Software
- 212 Applications
- 182 Command Line
- 3 Compiling/Installing
- 405 Games
- 311 Installation
- 79 All In Program
- 79 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)