Zhixian's Tech Blog

2015-10-15

Connecting to OpenSSH server using MobaXterm

Filed under: computing, ubuntu — Tags: , , , , , — Zhixian @ 14:19:10 pm

This blog post covers connecting to the openssh server installed on Ubuntu server using MobaXterm.

Testing OpenSSH

I want to connect to the openssh server.
For this purpose, I use MobaXterm from Mobatek (http://mobaxterm.mobatek.net/).
This is a terminal application with a few other tools built-in.
It has a professional edition which cost money and a home edition that is free.
For our local development purpose, the free edition is fine.

Alternatively, there’s the putty-series (http://www.putty.org/) of applications.

The remainder of this session assumes you are using MobaXterm.

After you start up MobaXterm, you may see a window like the below.
Click on the Session button on the menu.
This will open the Session Settings dialog.

image

On the Session Settings dialog, click on the SSH button on the top menu.

image

Under the Basic SSH settings tab, enter the name of the remote host.
Click the OK button to connect to the server.

image

After you clicked OK, MobaXterm will start your session on a new tab.
You should see your usual login prompt.
You should be able to login to your account as usual.

image

File transfer using SFTP

You can transfer files from your Windows machine to your Ubuntu machine using SFTP (Secure-FTP).
One the tools built-in the MobaXterm client is a SFTP client.
Click on the SFTP tab to display the directory and files in the directory.

image

To transfer files, simple drag and drop the files that you want to transfer in the area showing files in specified directory.

2013-06-22

How to connect to Microsoft Sql Server from Ubuntu via ODBC using FreeTDS

Filed under: computing — Tags: , , , , , , , — Zhixian @ 22:08:06 pm

This post describes the steps carried out to test my connection to Microsoft Sql Server from Ubuntu using ODBC.
This is part of my “How to connect to Sql Server from Ubuntu” series of blog post.

Assumptions

  1. The version of Ubuntu used in this guide is Ubuntu 12.04.2 LTS (Precise Pangoline) 32-bit.
  2. You are trying to connect to Microsoft Sql Server 2008 or later.
  3. You know how to use a terminal session in Ubuntu.
  4. You have installed unixodbc.
  5. You have installed freetds.

Note: Some of configuration files may be sitting in folders where your default user account may not have permission to edit them.
It is assume that that you will use “sudo” to gain the necessary elevated permission to edit the file if this happens.

Information required

  1. Location of odbcinst.ini file.
    This file is where you will be placing configuration details of any ODBC drivers that you will be using.
    If you have followed the steps in the previous blog post, this file should be at /usr/local/etc/odbcinst.ini
  2. Location of the freetds drivers.
    If you have followed the steps in the previous blog post, this file should be at /usr/local/lib/libtdsodbc.ini

Configuration overview

  1. Add driver configuration information for freetds
  2. Test freetds
  3. Configure freetds.conf for Sql Server connectivity testing
  4. Test connection
  5. Troubleshooting notes

Add driver configuration for freetds

1) Edit your /usr/local/etc/odbcinst.ini.
It should be blank. Add the following lines to the file and save the file.

[FreeTDS]
Description    = FreeTDS unixODBC Driver
Driver        = /usr/local/lib/libtdsodbc.so
Setup         = /usr/local/lib/libtdsodbc.so

Test freetds

After you have configure the driver, you can test the connection to your Sql Server.
We will use the tsql command to test the connection.

1)  Start a terminal session. Type tsql –C on the command line.

This command displays some of freetds configuration.
You should see results like the below.

image

Of note is the freetds.conf directory. This file is used to define Sql Servers aliases as well as freetds driver default settings.

2) Assuming you manage to display the configuration information, this means that your freetds setup correctly.
The next thing to try to do is probe for your Sql Server.
You do thing by typing the command tql –LH <machine_hostname>

<machine_hostname> can be hostname or an IP address.
In the screen below, the machine that host my Sql Server is SARA, so I typed tsql –LH SARA

image

From the above results, I can see that I have 2 instances of Sql Server installed on the host SARA.
It is important to note the TCP port number used by the server instance.
For the remainder of this post, we will try to connect to the SQLEXPRESS instance.
But prior to that, we will need to add a configuration setting in order to use the tsql command to connect to Sql Server.

 

Configuring freetds.conf

1) Remember the freetds.conf  file that you noted in step 1 of under test freetds? The one located at /usr/local/etc/freetds.conf ?
There are content in this file. But you don’t really need them at this stage. What you really need are just the following lines:

[global]
tds version = 8.0

Save the file.
The reason this step is required is because the tsql command utility do not have any parameters that allow you to specify the TDS version that it should use to connect to Sql Server. This is a problem when trying to connect to Sql Servers 2005 or later.
Hence, we set it as a global setting so that the default TDS version that driver will revert to is version 8.0

Test connection

1) Now you can use the tsql command to connect to your Sql Server.

Assuming my database user account is dbadmin, I would connect to the server by typing the following at the command line:
tsql –S SARA\\SQLEXPRESS –U dbadmin

If you get a screen like the below, it means you have successfully connected to your Sql Server.

image

You can run sql statements in this shell.
Type quit in the shell to exit.

image

 

Troubleshooting notes

Problem 1)

If you get a message like “There was a problem connecting to the server” as per the screen below, check your freetds.conf file and make sure tds version is set to 8.0 under global settings section.

image

 

Problem 2)

Another problem you might encounter when test is the following.
You appear to have logged in successfully, but you get a  running numeric prompt that starts from 1, 2, 3, …until such a time it timed out.

image

Essentially, it means tsql was not able to locate the server.

Checkpoints for this problem are:

  1. Is this correct server?
    If you are trying to connect to a database instance, you should specify tsql –S SARA\\SQLEXPRESS –U dbadmin
  2. Is the server running on default port?
    Note the TCP used by Sql Server by using the tsql –LH <machine_hostname> command. Then try the tsql command again by specify the port number with –p parameter. That is to say:
    tsql –S SARA\\SQLEXPRESS –U dbadmin –p 1433

 

Hope this helps anyone who had trouble setting up connection to Sql Server from their Ubuntu boxes.

Blog at WordPress.com.