LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 07-03-2020, 10:48 AM   #1
dlanced
Member
 
Registered: Apr 2014
Location: Canada
Distribution: Ubuntu, Kali Linux
Posts: 36

Rep: Reputation: Disabled
Enabling sshd from within a chroot


Ok. I may be making this way too complicated, but I'm trying to run Kali Linux as a VM on VirtualBox. It installed without trouble, but when I run it, it boots to a black screen. I've read that Kali doesn't play nicely with all graphics drivers (my host is running Radeon). I tried adding a
Code:
radeon.modeset=0
parameter to the GRUB code, but that didn't help.
The thing is that I don't need a GUI desktop here, and Kali itself will launch nicely under headless mode in VirtualBox. The other thing, though, is that Kali's default is to disable SSH server.
So I attached the Kali VDI disk to a different VirtualBox VM and booted it. I then created a chroot mount and installed openssh-server. But that didn't actually start (or enable) the service, and systemctl enable won't run under a normal chroot environment. So I copied the contents of the /etc/systemd/system/sshd.service file from a different system and pasted them into the chroot version of the directory. Since the file permissions are supposed to look like this:

Code:
lrwxrwxrwx 1 root root   31 Mar 19  2019  sshd.service -> /lib/systemd/system/ssh.service
...I fixed them and created a symlink to /lib/systemd/system/ in the chroot. I also enabled password login in the /etc/ssh/sshd_config file.

But it's still no go. nmap shows me the Kali box is running, but the SSH port is shut tight. Any ideas?
 
Old 07-03-2020, 12:43 PM   #2
dlanced
Member
 
Registered: Apr 2014
Location: Canada
Distribution: Ubuntu, Kali Linux
Posts: 36

Original Poster
Rep: Reputation: Disabled
It occurred to me that some might ask why, if I don't need a desktop, don't I just run Kali in an LXD container? Well, I tried. The problem there was that I'm running OpenVAS, which failed because I wasn't able to get redis-server to launch within the container. I suspect that redis failed because it was configured to listen on a custom socket:
Code:
ERROR: redis-server is not running or not listening on socket: /var/run/redis-openvas/redis-server.sock
...which might be something a container can't handle without full kernel access?
 
Old 07-03-2020, 01:28 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 20,228

Rep: Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460
Unless you installed the experimental pci pass through extension pack your still using a virtual GPU adapter so not sure what is happening unless your VM system settings are wrong.

The default adapter mode is NAT which basically acts like a router. Add a firewall rule to allow ssh traffic or switch to bridged mode.

Network and ssh need to be enabled and chroot has its own difficulty. Not enough information to know how anything is configured.

I downloaded the pre-built kali ova, imported it and had a VM with networking enabled in a matter of a few minutes.
 
Old 07-03-2020, 01:35 PM   #4
dlanced
Member
 
Registered: Apr 2014
Location: Canada
Distribution: Ubuntu, Kali Linux
Posts: 36

Original Poster
Rep: Reputation: Disabled
Quote:
Unless you installed the experimental pci pass through extension pack your still using a virtual GPU adapter so not sure what is happening unless your VM system settings are wrong.
I'm also not sure. But I will look into that.
Quote:
The default adapter mode is NAT which basically acts like a router. Add a firewall rule to allow ssh traffic or switch to bridged mode.
VBox isn't the problem with SSH: it's Kali which, by default, disables incoming SSH at the OS level. What I'm trying to do with chroot is make all the file system changes I'd need to get the same result as:
Code:
systemctl start ssh
systemctl enable ssh
Quote:
I downloaded the pre-built kali ova, imported it and had a VM with networking enabled in a matter of a few minutes.
I tried that, too. But the image uses Ubuntu 16.04. I need Kali (and a more recent version).
Thanks!
 
Old 07-03-2020, 01:39 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 20,228

Rep: Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460
The ova I downloaded is 2020.2 I believe and will check in a bit.
 
1 members found this post helpful.
Old 07-03-2020, 01:54 PM   #6
dlanced
Member
 
Registered: Apr 2014
Location: Canada
Distribution: Ubuntu, Kali Linux
Posts: 36

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
The ova I downloaded is 2020.2 I believe and will check in a bit.
Wait. What I said before (about Ubuntu 16.04) makes no sense. I was thinking about the Docker OpenVAS container I'd been looking at. My problem with the OVA image was that I couldn't get it running. I'm going to take another look at it now, though.
 
Old 07-03-2020, 02:24 PM   #7
dlanced
Member
 
Registered: Apr 2014
Location: Canada
Distribution: Ubuntu, Kali Linux
Posts: 36

Original Poster
Rep: Reputation: Disabled
I imported the OVA image and ran it, but it's also booting to a black screen. I'm 100% sure I never installed the PCI passthrough module. So I'm back to trying to open up SSH and run it headless.
 
Old 07-03-2020, 03:01 PM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 20,228

Rep: Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460
I don't know.

I am running VB 6.1.10 on a CentOS 7 hosts with kali 2020.2 ova with the graphics adapter setting VMSVGA. The host is an old Dell Optiplex 780 with an integrated Intel graphics controller but I don't if it matters.

With the virtual network adapter set to bridged and Kali does not have any firewall rules so once ssh was enabled I could easily login ssh from my host.

At the boot menu select advanced options and the 2nd line which is recovery mode. Since root is disabled by default it will automatically switch to console mode. From there you can login and I have not tried but you should be able to switch to multiuser instead of graphical mode which will enable you to run it headless.

Last edited by michaelk; 07-03-2020 at 03:10 PM.
 
1 members found this post helpful.
Old 07-03-2020, 03:09 PM   #9
dlanced
Member
 
Registered: Apr 2014
Location: Canada
Distribution: Ubuntu, Kali Linux
Posts: 36

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
I don't know.

I am running VB 6.1.10 on a CentOS 7 hosts with kali 2020.2 ova with the graphics adapter setting VMSVGA. The host is an old Dell Optiplex 780 with an integrated Intel graphics controller but I don't if it matters.

With the virtual network adapter set to bridged and Kali does not have any firewall rules so once ssh was enabled I could easily login ssh from my host.
You mean you didn't even need to install and enable SSH within Kali? I'm on a bridged adaptor and, while the Kali VM (running headless) shows up in nmap, port 22 isn't open. I suppose that could be because the installation isn't complete until I successfully log into the GUI at least once.
Thanks,
 
Old 07-03-2020, 03:13 PM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 20,228

Rep: Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460
I edited my last post to include booting to console mode and was trying to see if it worked... It didn't

Yes, ssh was already installed and I just had to enable/start it.
 
1 members found this post helpful.
Old 07-03-2020, 03:37 PM   #11
michaelk
Moderator
 
Registered: Aug 2002
Posts: 20,228

Rep: Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460
update: how to boot to console mode.

When you see the grub boot line showing the kali kernel press e to edit grub. Move the cursor to the end of the kernel line and add
systemd.unit=multi-user.target

Press F10 to boot.

login by default
username kali
password kali

To switch to multi-user mode

sudo systemctl set-default multi-user.target
 
Old 07-03-2020, 03:45 PM   #12
dlanced
Member
 
Registered: Apr 2014
Location: Canada
Distribution: Ubuntu, Kali Linux
Posts: 36

Original Poster
Rep: Reputation: Disabled
Thanks. I got the same black screen. Same for rescue.target. But I think this problem isn't specific to Kali, since I'm getting the same problem with the other desktop VM on my system (Ubuntu 20.04). I see that other people are sharing in my suffering:
https://blog.softhints.com/virtualbo...tu-linux-mint/
 
Old 07-03-2020, 03:53 PM   #13
michaelk
Moderator
 
Registered: Aug 2002
Posts: 20,228

Rep: Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460Reputation: 3460
Interesting. I have only run into a few really old distributions that had a VB black screen boot problem. I am running on a Dell 790 the latest Mint, Ubuntu and debain as VMs.

Kind of hard to install guest additions if it will not boot to a desktop...
 
Old 07-03-2020, 03:59 PM   #14
dlanced
Member
 
Registered: Apr 2014
Location: Canada
Distribution: Ubuntu, Kali Linux
Posts: 36

Original Poster
Rep: Reputation: Disabled
VBox was working perfectly the last time I used it (probably a month or so back). I'm running Ubuntu 18.04 on a powerful enough system (16GB memory, SSD storage, Ryzen 3 2200G). I'm planning to upgrade it to 20.04 in the next few weeks. If I haven't come to grips with the problem by then, I'm curious to see whether that'll make a differenct.
 
Old 07-03-2020, 05:46 PM   #15
dlanced
Member
 
Registered: Apr 2014
Location: Canada
Distribution: Ubuntu, Kali Linux
Posts: 36

Original Poster
Rep: Reputation: Disabled
Well I bit the bullet and downloaded VMware Player. It got Kali up and running in no time. I'm not sure this solved the problem, but it's a valid workaround.
 
  


Reply

Tags
chroot, kali linux, ssh access, virtualbox


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
question: 'onclick' within 'onmouseover' within 'form' within 'table' - how is it possible? rblampain Programming 4 04-25-2017 08:49 PM
Chroot in shell scripts: Ensuring that subsequent commands execute within the chroot Kenny_Strawn Programming 2 05-21-2012 12:25 PM
Starting sshd: /etc/init.d/sshd: line 113: /usr/sbin/sshd: Permission denied sumanc Linux - Server 5 03-28-2008 04:59 AM
FC4-Starting sshd: Privilege separation user sshd does not exist FAILED kiranherekar Fedora 5 12-29-2005 02:22 PM
Enabling SSH in mandrake 9.2 - sshd vs. sshd-xinetd DogTags Linux - Newbie 7 11-25-2003 12:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

All times are GMT -5. The time now is 11:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration