Say what? This is probably well known by people that knows Linux a little more than average. I often have Kali Linux running on Hyper-V and I often struggle with resolution using the native Hyper-V console. After a little research I found out that I can install xrdp on the Kali machine and be able to RDP directly into the Kali machine. This post is meant as a reminder to myself on how to do this later in life….
The following steps assumes that you have installed Kali Linux from the latest ISO and did the update procedure:
- Apt-get update && apt-get upgrade
- Apt-get dist-upgrade
In order to install the RDP server you run the following command from a terminal window:
- Apt-get install xrdp
After xrdp is installed you can start the server with the following command:
- Service xrdp start
- Service xrdp-sesman start (Thanks to Greg for pointing that out) — UPDATE!!
- If want it to auto start after reboot you need to run this command also:
update-rc.d xrdp enable (It will not start xrdp-sesman automatic)
Now you should be able to RDP directly into your Kali Linux:
The only problem is that right now there is a bug in the distro (kali/debian with GNOME) causing both VNC and RDP to cause this error message after login:
(UPDATE: In newer Kali versions this screen is not present. Instead nothing is happening)
The only way I found that fixes this is to uninstall the Gnome-desktop and use another window manager (I use LXDE):
- Apt-get remove gnome-core
- apt-get install lxde-core lxde kali-defaults kali-root-login desktop-base
-
update-alternatives –config x-session-manager
- Choose /usr/bin/startlxde
After this you need to reboot and the RDP should work “perfectly”
A full list of windows managers can be found here:
Update 30.09.2016:
There seems to be an issue that causes protocol error. This is if you use 32 bit color depth in the RDP client. Use a lower number and you should be good.
Thanks for that little nugget at the end that saved the day for me. I too was in the same situation as you, without being able to RDP into Kali on my ESXi and was staring at that error message. Changing the desktop manager to lxde was fantastic.
Removing gnome is not a good idea. lxde is stupid. there’s nothing there. you go to run and type terminal you get an error. there’s no sidebar or anything. do not do it
I removed the gnome. I regreted it at first, but then, with a little bit of exploring i found everything that i need.
If you want to find the terminal go to Start -> Usual applications -> System Tools -> LxTerminal.
Just get a shortcut of the terminal, and do all the other stuff with only commands. For my opinion this is the best option if you wan’t to be better at typing and in the same time, memorise more commands.
Thanks for Oddvar Håland Moe so much!
I spent one whole day yesterday to do this,and finally I succeeded now!
Actually I read this article yesterday and follow steps above,but I encountered some error at this step:
apt-get install lxde-core lxde kali-defaults kali-root-login desktop-base
so I failed.
and then I searched lots of pages by google,but I can’t find valuable articles about RDP for kali linux.
I retry again this morning,and it is done!
update-alternatives –config x-session-manager
should be
update-alternatives –config x-session-manager
two dash —
The last bit saved the day! Thanks a ton!
Thanks so much for the tip. It saved my sanity after trying all sorts of things. The update-alternatives bit didn’t work for me for some reason (even with two dashes) so I just edited my ~/.vnc/xstartup to include /usr/bin/startlxde and that seems to work fine.
how to edit ~/.vnc/xstartup
Thanks for the info. After days of searching and testing
Finally it is running
So awesome trick.Thank You!!
This is awesome – huge timesaver for me! Thank you!
Anyone else having issues running wireshark after performing this?
I have the same issue . any solution?
yes, problem in wireshark.. its just ending and closing.. lol
So As a noob how does the cmd line look with the 2 dashs ?
Thank you for sharing this information it was helpful
This easy installation instruction helps me to activate XRDP on KALI – thank’s a lot.
But when I try to run wireshark (execute it in terminal) the following error message appears:
Qt: XKEYBOARD extension not present on the X server.
The X11 connection broke: Maximum allowed requested length exceeded (code 4)
XIO: fatal IO error 0 (Erfolg) on X server “:10.0”
alfter 195 requests (195 known processed) with 0 events remaining.
Do you have any idea how to solve this problem. Unfortunately I didn’t find a solution so far.
Thanx a lot in advanced,
TW
I had to add startlxde into /etc/xrdp/startwm.sh and comment out /etc/X11/Xsession. Now it works great!
Thank you very much !!!!! Oddvar Moe
You are welcome
maybe I am way off but I cant even seem to find that package keeps coming back with unable to locate package.
This worked for me
https://www.linkedin.com/pulse/kali-linux-fix-unable-locate-package-eyripidis-stefanidis
Thanks much! brough two days of agony to a close.
linux cmd lines are case sensitive; it is not an something that should be needed explained but for those that it is. You are misinforming.
Okay. Have I done a typo? What are you referring to?
Apt instead of apt
I cant get logged in no matter what at the moment. I put kali in the cloud ssh into with no issue useing putty on my windows10 i tunnel my ssh session and open rdp. I get the xrdp login screen with what looks like in the backgroud my cloud. No matter what setting i use such as vpn-any, nothing happens it says vpn connection error. If i put username and password it will just load then null. anyone have ideas???
James – I believe I am having a similar issue to you. Here is my config:
Kali deployed to Azure. I have allowed RDP and configured above as per Oddvar Moe. However when I try to RDP I get presented with the following GUI screen:
“XRDP (inside of what looks like a multi colored nucleus) Just connecting” I have the option for a bunch of different session types:
– sesman-xorgxrdp
– sesman-Xvnc
– console
– vnc-any
– sesman-any
– rdp-any
– neutrinordp-any
– Session manager
Depending on what I pick I get different user/password/ip/port options. No matter what I pick and click OK it just doesn’t do anything.
Any thoughts anyone?
Ok, I got my issue resolved. Looks like the xrdp session manager also needs to be running.
service xrdp-sesman start
I found this on: https://forums.kali.org/archive/index.php/t-32480.html. Take a look at the second post by: mjdx88. The combination of mjdx88 and Oddvar Moe got me going.
Thanks,
Greg
root@kali:~# update-alternatives –config x-session-manager
update-alternatives: error: unknown argument ‘–config’
———————————
root@kali:~# update-alternatives ––config x-session-manager
update-alternatives: error: unknown argument ‘––config’
———————————
Thanks for posting this.
I recently got this working on Kali 2016.2 rolling update version and have some notes for the post:
Depending on the version of Kali you may need to change up the repo’s:
cat < /etc/apt/sources.list
deb http://http.kali.org/kali kali-rolling main non-free contrib
EOF
apt-get update
apt-get dist-upgrade # get a coffee, or 10.
reboot
Also – no need to uninstall GNOME. There are compatibility settings for GNOME that you can envoke by typing xfce4-settings-manager. There are compatibility checkboxes for both GNOME and KDE.
here were the commands used:
apt-get install xrdp
apt-get install xfce4
gedit /etc/xrdp/startwm.sh
# add this line before line /etc/X11/Xsession
xfce4-session
xfce4-settings-manager
#goto session and startup compatibility -> advanced Launch GNOME services on startup
service xrdp restart
#looks like it needs to be typed in every reboot:
service xrdp-sesman start
Cheers,
scratch the last two lines
just type in
update-rc.d xrdp enable
and the service will begin on startup
Dude, you rock with the xfce4 tips! Very Very helpful, without having to switch from Gnome! Many thanks.
thanks worked great in gnome
Just tried this today. I got to the part where I got the blank screen, so I removed gnome and installed lxe. After reboot, RDP didn’t connect and I get an error when trying to start xrdp. Wrong permissions? I”m running as root.
root@kali:~# service xrdp start
Job for xrdp.service failed because the control process exited with error code.
See “systemctl status xrdp.service” and “journalctl -xe” for details.
root@kali:~# journalctl -xe
Oct 31 10:17:01 kali CRON[1757]: pam_unix(cron:session): session closed for user
Oct 31 10:17:08 kali realmd[1392]: quitting realmd service after timeout
Oct 31 10:17:08 kali realmd[1392]: stopping service
Oct 31 10:17:10 kali dbus-daemon[1473]: Activating service name=’org.gnome.GConf
Oct 31 10:17:10 kali dbus-daemon[1473]: Successfully activated service ‘org.gnom
Oct 31 10:20:40 kali systemd[1]: Starting xrdp (X Remote Desktop Protocol) proto
— Subject: Unit xrdp.service has begun start-up
— Defined-By: systemd
— Support: https://www.debian.org/support
—
— Unit xrdp.service has begun starting up.
Oct 31 10:20:40 kali sh[1912]: E: /var/run/xrdp has wrong permissions
Oct 31 10:20:40 kali systemd[1]: xrdp.service: Control process exited, code=exit
Oct 31 10:20:40 kali systemd[1]: Failed to start xrdp (X Remote Desktop Protocol
— Subject: Unit xrdp.service has failed
— Defined-By: systemd
— Support: https://www.debian.org/support
—
— Unit xrdp.service has failed.
Greetings from Singapore. Thank you so much for your write up 🙂 it helps me a lot. 2 thumbs up 🙂
Hello,
now i everytime have to connect with ssh and type “service xrdp-sesman start” and then i can connect with remotedesktop is there a solution for starting also “xrdp-sesman” on booting?
Kali 2.0 by default allow RDP login for root only.
To allow rdp login for rest users:
vim /etc/X11/XWrapper
change allowed_users=console to allowed_users=anybody
Some hint:
Wenn you have problems to start xrdp-sesman, which will try to start automaticly with xrdp, you should look, if the directoy “/var/run/xrdp” exists. In my case it was not created by default. Without these directory not pid file coud be written by the xrdp-sesman deamon.
Has anyone gotten xrdp to work recently? When I try to start the services I get errors for both “service xrdp start” and “service xrdp-sesman start”
root@kali:~# service xrpd start
Failed to start xrpd.service: Unit xrpd.service not found.
root@kali:~# service xrdp-sesman start
Job for xrdp-sesman.service failed because of unavailable resources or another system error.
See “systemctl status xrdp-sesman.service” and “journalctl -xe” for details.
i have found a way for th xrdp-sesman service to start automatically. I used of course “update-rc.d xrdp enable” to have xrdp itself to start on boot but xrdp-sesman needs to start also if you add the following “systemctl enable xrdp-sesman.service” After which time you should reboot & you should be good. I use KDE & I didn’t need to use lxde. Although on another vmware workstation machine that was the only way I could get it work by installing the lxde environment.
Boom!!! Thanks Wolverine_75212, worked perfectly. This should get added to the article.
mikeb,
glad I could help, cause i know this had been plaguing me for a while with a new kali upgrade & seen many folks having the same issue.
Hi,
I found that the command below had to have ‘sudo’ in front to recognise the ‘–config’ option otherwise it failed, even when logged in as root.
The below worked for me.
sudo update-alternatives –config x-session-manager
Choose /usr/bin/startlxde
Thanks
Multiple RDP Sessions?
I go this working following the directions above (Kali Linux), but I can only login once. The second RDP connection terminates the first one.
Goal is to 5 sessions! Any suggestions?
my RDP to Kali problem is solved… thank you Oddvar Moe
It is absolutely perfect job! Thank you for this great support article.
i configured Azure RHEL 7.4 VM , while connect using RDP getting below error,
Connecting to sesman IP 127.0.0.1 port 3350
sesman connect ok
sending login info to session manager, please wait…
login successful for display 10
VNC started connecting
VNC connecting to 127.0.0.1 5910
VNC error-problem connecting
working fine for Azure RHEL 7.4 VM
$sudo su –
#yum groupinstall ‘Server with GUI’
#systemctl stop firewalld
#systemctl disable firewalld
#yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#yum install xrdp tigervnc-server xterm
#systemctl enable xrdp
#systemctl enable xrdp-sesman
For the newer distro of Kali:
apt-get install xfce4
apt-get install xrdp
echo xfce4-session >~/.xsession
service xrdp restart
Kali VM open-port –resource-group myResourceGroup –name myVM –port 3389
use xvnc to connect
Michael – Thanks for posting this. I was able to get RDP working with a combination of your post and one other command. Since this is for an isolated lab, I am using root for the RDP login and haven’t tried any other accounts.
# I used this from a post above to link xrdp and xrdp-sesman
systemctl enable xrdp-sesman.service
apt-get install xfce4
apt-get install xrdp
echo xfce4-session >~/.xsession
service xrdp restart
# I did not have to do this.
open-port –resource-group myResourceGroup –name myVM –port 3389
The biggest key was to use XVNC with the RDP login after connecting via my local RDP client.
Note: Since this is for an isolated lab, I am using root for the RDP login and haven’t tried any other accounts.
Thanks!
thank you for this guide. Kali linux now works much better through hyper-v after removing gnome-core and switching to LXDE.
Or……….
You could save yourself a LOT of time by simply downloading and installing the LXDE version from available downloads:
Kali Linux Lxde 64 Bit here:
https://www.kali.org/downloads/
Then…..
1. Apt-get update && apt-get upgrade
2. Apt-get dist-upgrade
3. Apt-get install xrdp
4. systemctl enable xrdp
5. systemctl enable xrdp-sesman
Done.
This is a LOT faster and easier!
not an option for all download…arm distro’s only offer one flavor.
Copy and Paste is not working for me after following thi proc
not working !!!
Blank blue screen after completing the same.
Look what i found. a simple easy work around for this confusing problem
[youtube=https://www.youtube.com/watch?v=cWQsLVAVCN4&w=640&h=360]
OMG Oddvar I love you ! A whole day of frustration following other guides and here you are one of my twitter heroes saving me once again. Thank You!!
You are very welcome. Happy that this old blog post helped you out
hi Moe,
many thanks for this helpful article.
It works and run as expected.
good job