Having SSH access to a server I need to install and configure remote access using a Command Line Interface, To access Server using VNC or Terminal Server Client

To enable the GUI:

yum -y groupinstall "GNOME Desktop" && systemctl set-default graphical.target && shutdown -r now

But I can't find any solution for enabling Remote Administrative Access using command line only. CentOS documentation shows how to do it using a GUI (if you have access to GUI), but nothing about command-line options or at least which config files are getting edited with GUI interface in this case...


Does anyone knows how to do it?

  • I'm not looking for a solution to "install and configure remote access USING a graphical interface, I know exactly how to do it using the graphical interface, I'm looking for a solution to enable it using a Command Line Interface trough ssh. About a Documentation, Unfortunately I cannot find anything related to CentOS7, only solution's to install VNC server etc.. – Zaza Jan 8 '17 at 2:49
  • What is the name of the software that you need to configure via SSH? The documentation just says "Remote Desktop". If you're not sure, check with ps ax. – Emmanuel Rosa Jan 8 '17 at 4:00
  • To be honest I never used Remote desktop on Linux, but according this CentOS document, linux's remote desktop is designed similar to Windows servers, you need to enable Remote access to Desktop first, to connect , with any supported client – Zaza Jan 8 '17 at 4:09

Given are the steps to install and configure VNC server in centOs:

  1. ~]# yum install tigervnc-server
  2. ~]# cp /usr/lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
  3. ~]# vim /etc/systemd/system/vncserver@:1.service

replaced USER with riddhi in this file

ExecStart=/usr/sbin/runuser -l USER -c "/usr/bin/vncserver %i -geometry 1280x1024"
  1. ~]# systemctl daemon-reload
  2. ~]# su - riddhi
  3. ~]$ vncpasswd //update password for user riddhi
  4. ~]# systemctl start vncserver@:1.service
  5. ~]# systemctl enable vncserver@:1.service

Now connect to centOs from Windows:

  1. IP: ip address:5901

  2. password : password of vncpasswd


If you are looking to enable remote access to the 'root' account and you are willing to accept those risks, then uncomment the following line in /etc/ssh/sshd_config

PermitRootLogin yes

Then restart the ssh daemon

service sshd restart

then you can SSH into the system with


If you are using another user then of course you could just

ssh username@SERVER_IP_ADDRESS

If you are getting and Access Denied I would turn off the firewall to verify if that is the issue or not.

A slightly less risky alternative would be to setup ssh keypairs (so you don't need to type in your password every time you connect). And also configure your user so that they aren't prompted for a root password every time you sudo.

  • I believe you are talking about SSH access ? or I'm missing something ? If I'm right, in CentOS unlike Debian SSH is enabled by default ... I'm looking for a solution to enabling Remote Administrative Access / (RDP like) – Zaza Jan 8 '17 at 2:01
  • Not all linux distros are same configuration and packages installed.You can install vnc/x11vnc server to remote Administrative Access.You are familiar with Debian.You should use Debian. – supriady Jan 8 '17 at 2:48
  • It's not my choice, I have to do it using the CentOS7 .... – Zaza Jan 8 '17 at 2:59
  • Its not clear what exactly you are looking for. You asked about "Remote Administrative Access " via command line . To me that says SSH. If you are referring to using the GUI, then you will need VNC. If you need for this to access via "root" user, you will need to edit the /etc/ssh/sshd_config file. – ddlingo Jan 8 '17 at 18:51
  • OPP provided a link in problems description, I believe it is clear enough what CentOS developers call "Remote Administrative Access" – user209328 Jan 11 '17 at 20:46

Installing VNC worked for me, so it seems in CentOS7, nothing really needs to be enabled trough (GUI) for instance from GNOME. Created a small script so anyone else can use if needed. for CentOS7

yum -y groupinstall "GNOME Desktop" && 
systemctl set-default graphical.target && 
yum install -y tigervnc-server &&
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:4.service &&
systemctl enable vncserver@:4.service   &&
sed -i 's/<USER>/root/g' /etc/systemd/system/vncserver@:4.service &&
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:5.service &&
cat <<"EOF" >> /etc/systemd/system/vncserver@:5.service
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
systemctl enable vncserver@:5.service &&
#  Setting Firewall rules
firewall-cmd --permanent --zone=public --add-port=5904-5905/tcp &&
firewall-cmd --reload &&
#setting password for vnc access
vncserver &&
#restarting services
systemctl daemon-reload &&
systemctl restart vncserver@:4.service &&
systemctl restart vncserver@:5.service &&
shutdown -r now 

On this stage you should be able to log in using VNC client. For me "Realvnc" worked fine others did not for some strange reason... Please note :

  1. connection ports are 5904 and 5905
  2. If you need more simultanius connections to be enabled for free ;) Unlike Windows :), just add more :
    • /etc/systemd/system/vncserver@:6.service
    • /etc/systemd/system/vncserver@:7.service
    • /etc/systemd/system/vncserver@:8.service
      etc... and make sure ports 5906,5907,5908 are not busy with some other app.
  3. Firewall rule may need to be altered, depending to what zone your network interface belongs to.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.