Showing posts with label SSH. Show all posts
Showing posts with label SSH. Show all posts

Using ssh, scp, sftp

SSH
The server node should be running the SSH server

sudo aptitude install openssh-server

Connect to the server

ssh username@ipaddress:port

Connect to the server with X enabled

ssh username@ipaddress:port

Note: specify port only if the default 22 is not being used.

SCP
scp can be used to transfer the files between the nodes (works on top of SSH)

From remote node to local node

cd local_folder
scp username@ipaddress:port:/home/username/path/to/folder_file .


From local node to remote node

scp /path/to/local/folder_file username@ipaddress:port:/home/username/path

SFTP
If you have a luxury of a GUI, you can copy using sftp.

Open nautilus (if using Gnome) and type in the location bar the address to the server.

nautilus --no-dektop --browser
Location Bar: sftp://username@ipaddress:port/home/username


Although you can go to the root folder as well, but is not a good practice to screw around in that area

Getting the VPN to work

Update: Doesn't work

-+-

After connecting to the VPN server, can't access the sites. Need to add stuff to the routing table. Wrote the bash script for that:

Soon after getting connected on VPN, do ifconfig, get the IP address associated to the ppp0 (p-t-p), specify your local router gateway and the interface you are connected through (wireless or wired) and fire the script!

#!bin/sh
# Check for command line
if [ -z "$1" ]; then
  echo "usage: ./vpn.sh [p-t-p] [GW] [Interface]"
  exit
fi

if [ -z "$2" ]; then
  echo "usage: ./vpn.sh [p-t-p] [GW] [Interface]"
  exit
fi

if [ -z "$3" ]; then
  echo "usage: ./vpn.sh [p-t-p] [GW] [Interface]"
  exit
fi

VPN_REMOTE_IP=$1
ALLTARGET="198.82.0.0/16" # All class C addresses
GATEWAY=$2
INTERFACE=$3 #eth0 or eth1

# change!
route add -host $VPN_REMOTE_IP gw $GATEWAY dev $INTERFACE
route add -net $ALLTARGET dev ppp0


Run this script as sudo!

Using VNC over SSH

Okay, now I need to connect to this Linux box in the department which is running Matlab and access it on the wire.

Options:

1. SSH + X11 forwarding [slow]

% ssh -X username@hostname
% matlab &


In order to have SSH forward X11 by default change the following in /etc/ssh/ssh_config and also remove the #

ForwardAgent yes (default no)
ForwardX11 yes (default is no)
StrictHostKeyChecking no (default is ask)


With this you can now use

ssh username@hostname

2. VNC without SSH. [fast]
% vncviewer hostname:display

3. VNC tunneling over SSH [faster]
% ssh -C -L 5901/localhost/5901 username@hostname
% vncviewer localhost:5901


Ensure that vncserver is running on the remote node and also that you have set your vncpasswd. The "display" is the number that you get after starting the vncserver

NOTE:
If you are running compiz\beryl (any composite window manager), Matlab's pre-bundled java does not support it and hence it would not render it properly with option (1). You would have to point to the latest version of the JVM before starting matlab

% export MATLAB_JAVA=/usr/lib/java/blah-blah/jre
% matlab &


Update:
Got a local copy of Matlab and realized that it has the same problem and is solved by pointing to the latest JVM. Create a launcher that takes care of setting up the environment before the launch.

env MATLAB_JAVA="/usr/lib/jvm/java-6-sun/jre" xterm "/home/piyush/matlab-2007b/bin/matlab"