How to: Create remote access & desktop. SSH

Write tutorials and howtos in here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please. Before you post please read this

How to: Create remote access & desktop. SSH

Postby Krzychu on Sun Jul 06, 2014 5:16 pm

Remote desktop... something you will love if you have few computers and maybe a small, home file server. To be honest, if for some reason you had to configure your router/modem - you did it remotely! But I'm not going to tell you why remote access is beautiful, I'm going to make a nice tutorial. I hadn't luck to find tutorial that would gave me all informations I needed so I write this. And it turned out to be easy peasy. Also I will tell you how to do it in secure way.

Server - any PC we want to control remotely. It can even be tablet or smartphone.
Client - a computer what we will use to log in on server. Can also be a tablet (another one).
I'm using desktop as server and laptop as client. Both LM 17.

First, server. Interesting thing for you may be Wake On Lan (WOL). It let you to start computer from other machine. Check Internet card informations if it support it. By default it's enabled on most computers. Just go to BIOS and make sure it's enabled. It don't have to be named "WOL" or "Wake On Lan". I saw also some other names for WOL in BIOS, but I forgot them. If you have WOL enabled and it doesn't work - your BIOS may have settings how deep he is going to be powered off (deep sleep state, something like that). There are many programs that send WOL packets (magic packets), but mint seems to have only one in repo: gwakeonlan. It's very simple and good :)
But most important thing on server is software that will let us remote access. Most popular is SSH. You can install both SSH client and server:
Code: Select all
sudo apt-get install ssh

or just server:
Code: Select all
sudo apt-get install openssh-server

And you're done with server. Here is tutorial how to secure your ssh server, if you want: http://www.cyberciti.biz/tips/linux-uni ... tices.html
I turned firewall on (via gufw) and disabled option to log in as root. Make sure port 22 is allowed in firewall.

Time for client. Install ssh client:
Code: Select all
sudo apt-get install openssh-client


After that you can log in remotely to your server if they are in same network. If they are in other networks then you also need to configure your router. If needed, I'll explain later. For now lets say we have them in same network: 192.168.1.X (mask: 255.255.255.0). Server IP is 192.168.10.15 for our purpose. Of course you can set other IP. It's good to have static DHCP so your server will always have the same IP.
Server user is an account that already exist on server!

In terminal use command:
Code: Select all
ssh user@ServerIP

or
Code: Select all
ssh user@ServerName

(first option if everything is done correctly will always work, second sometimes need router additional configuration - check DNS).
You have to write that user password.

Congratulations, you have now remotely connected to the server! Use exactly same commands as you use in terminal on client.
You can also use command:
Code: Select all
ssh -Y user@ServerName/IP

by this if you run any graphical application you will be able to normally use it. Very useful, for example if you need to use FileZilla.

"But I want to see whole desktop, not only interface of some program!"
First, you need program on SERVER to have remote desktop. There are 2 kind of remote desktop - native (if you sit in front of server monitor you will see exactly same things happening on desktop as you look on remote desktop - known as desktop sharing) desktop and new, virtual desktop (you have to remotely access that desktop).
Mint have default one - vino. It share native desktop. But this one isn't good for me. If you want: here is tutorial how to configure it via SSH: http://ubuntuforums.org/showthread.php? ... 13fa555a40
Too complicated. And for remote access I need something that others don't see (I made server from PC that is normally used). Look for "VNC Server" I use vnc4server:
Code: Select all
sudo apt-get install vnc4server

Run this command on server (can be done via SSH). Next, on server:
Code: Select all
vnc4server

or
Code: Select all
vnc4server -geometry [i]width[/i]x[i]height[/i]

if you want other desktop resolution (default: 1024x768).
write any easy password, remember it or write down. For this tutorial it's qwerty

Now, on CLIENT we need a vnc client. Open other terminal or use "logout" command to logout from remote server (Ctrl + D works as logout; use Ctrl + C if SSH will stuck)
I use SSVNC (it have many features, default settings are good).
Code: Select all
sudo apt-get install ssvnc

Now run it (from menu or type "ssvnc" in terminal).
VNC Host:Display - your server name/IP:Virtualdesktop, default is :0, hovever vnc4server start from :1
VNC Password - password you provided on server after command "vnc4server"
Proxy/gateway - might be interesting if your remote server is in another network
Remote SSH Command - command given here will be immediately executed on remote server after login
Use SSH (if you have enabled firewall and allowed only port 22; otherwise you can use anything).

So for me it looks like that:
Code: Select all
VNC Host:Display | 192.168.1.105:1
VNC Password | qwerty
Proxy/gateway |
Remote SSH Command |

VNC Host:Display may also be: servername:1
Press connect. Now you will need to provide user password (the one who started vnc4server) and you're done. You have remote desktop!

You can run more instances of vnc server - every next instance have +1 to :display (so third instance is :3).

Please let me know if this is helpful - I can make some screenshots and explain some other stuff mentioned here but not connected to remote access/remote desktop directly.

Regards,
Krzychu

If you want to copy whole or part of this tutorial, you're free to do so. Please provide a link to this topic and inform me about that via PM.
Krzychu
Level 2
Level 2
 
Posts: 54
Joined: Sat Mar 01, 2014 9:14 pm

Linux Mint is funded by ads and donations.
 

Re: How to: Create remote access & desktop. SSH

Postby Ka2 on Mon Jul 21, 2014 1:25 pm

Hi,

Have tested your tutorial and did not get the result I expected. Me being a newbie might be the problem... When I followed the steps in your tutorial I could connect to server pc. But got only a terminal window inside a grey screen and pop up menu. The terminal window was not writeable. SSH connection seemed to be ok. Could do cmd line on server after connection, but vnc connection was not as expected.

I guess this has to do with some configuration of ssh or vnc, that might be obvious to experienced linux users. I figured, after some time, out that I had to un# port 22 in ssh config file on server to get connected. But have not studied the manuals for ssh and vnc yet. But it might be an idea to tip readers how to config or inform that some configuration of ssh or/and vnc is needed..

But as I said I don't know what the problem is, I only guess..

Brgrds,
Ka2
Ka2
Level 1
Level 1
 
Posts: 6
Joined: Sat Jul 19, 2014 4:06 pm


Return to Tutorials / Howtos

Who is online

Users browsing this forum: No registered users and 7 guests