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: 56
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: 13
Joined: Sat Jul 19, 2014 4:06 pm

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

Postby Ka2 on Thu Jul 24, 2014 5:07 pm

Have been playing around with this for some time now and have not got the vnc connection to work as indicated in the howto article. I guess its my fault for not beeing able to configure thing correctly.

- So it would be welcome to have some more info on what is necessary to do, to get this to work...

Anybody care to educate me ??

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

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

Postby Krzychu on Mon Jul 28, 2014 6:38 am

Hey Ka2, sorry for late reply.
By default as far I remember port 22 is uncommented. But I might be wrong. I'm glad you have fixed this and your terminal SSH works correctly. About your VNC problem - you need to edit on your vnc server vnc config file. Run on server:
Code: Select all
nano ~/.vnc/xstartup


And make sure your config looks like this:

Code: Select all
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
exec mate-session


You do not have to copy # lines, but you might find them useful in future.
Krzychu
Level 2
Level 2
 
Posts: 56
Joined: Sat Mar 01, 2014 9:14 pm

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

Postby Ka2 on Mon Jul 28, 2014 9:30 am

Hi Krzychu,

Thanks for your reply and information! I will have a go at it, later this evening !

Brgrds,
Ka2
1.EDIT : I guess the ref to "mate session" is when you use a "mate" DE ?
2.EDIT : I still can't get it to work as described. I end up with a grey screen in a window, but no terminal window inside this time.
3.EDIT : Have now tried with tightvncserver also and get the same result, so it must be some config that is not right. Does it matter if the acount is in use one the PC to be connected ?
Ka2
Level 1
Level 1
 
Posts: 13
Joined: Sat Jul 19, 2014 4:06 pm

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

Postby Krzychu on Sat Aug 02, 2014 11:34 am

1. Yes, sorry, I'm using mate, if you have cinammon or other DE you have to replace mate-sessions to correct one.

2 & 3.
After installation of tightvncserver you should remove xstartup config file - it was using the old one, from vnc4server. Anyway try this one for vnc4server:

Code: Select all
#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
/etc/X11/Xsession


It's universal so should work with any DE. If you want to use tightvncserver then in console:
Code: Select all
rm ~/.vnc/xstartup

and start your tightvncserver. By this it will load it's default configuration, what is actually correct by default (or at least was 2-3 months ago - I'm sure because I did remove operation too).

You have to connect to account that have running vnc server. Otherwise it will fail. If you run vnc server on XYZ account, then to have to vnc log in on XYZ account. Trying to vnc log in on ABC will fail, because there is no vnc server running.
Krzychu
Level 2
Level 2
 
Posts: 56
Joined: Sat Mar 01, 2014 9:14 pm

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

Postby Ka2 on Sat Aug 02, 2014 6:06 pm

Hi Krzychu,

Thank for your reply!

I got it work, sort of, cinnamon crashes and goes to fallback. But it is workable... Best result so far..

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

Linux Mint is funded by ads and donations.
 

Return to Tutorials / Howtos

Who is online

Users browsing this forum: No registered users and 9 guests