diff --git a/pgadmin/dlg/dlgServer.cpp b/pgadmin/dlg/dlgServer.cpp
index a928930..a568a21 100644
--- a/pgadmin/dlg/dlgServer.cpp
+++ b/pgadmin/dlg/dlgServer.cpp
@@ -66,6 +66,7 @@
 #define pickerPublicKeyFile	 CTRL_FILEPICKER("pickerPublicKeyFile")
 #define pickerIdentityFile	 CTRL_FILEPICKER("pickerIdentityFile")
 #define stPublicKeyFile		 CTRL_STATIC("stPublicKeyFile")
+#define txtTunnelPort		 CTRL_TEXT("txtTunnelPort")
 #endif
 
 BEGIN_EVENT_TABLE(dlgServer, dlgProperty)
@@ -99,6 +100,7 @@ BEGIN_EVENT_TABLE(dlgServer, dlgProperty)
 	EVT_CHECKBOX(XRCID("chkSSHTunnel"),                dlgServer::OnCheckSSHTunnel)
 	EVT_RADIOBUTTON(XRCID("radioBtnPassword"),         dlgServer::OnChangeAuthOption)
 	EVT_RADIOBUTTON(XRCID("radioBtnKeyfile"),          dlgServer::OnChangeAuthOption)
+	EVT_TEXT(XRCID("txtTunnelPort"),                   dlgProperty::OnChange)
 #endif
 END_EVENT_TABLE();
 
@@ -160,6 +162,7 @@ dlgServer::dlgServer(pgaFactory *f, frmMain *frame, pgServer *node)
 	radioBtnPassword->SetValue(true);
 	radioBtnKeyfile->SetValue(false);
 	txtTunnelPassword->SetMaxLength(SSH_MAX_PASSWORD_LEN);
+	txtTunnelPort->SetValue(NumToStr((long)DEFAULT_SSH_PORT));
 #ifdef HAVE_OPENSSL_CRYPTO
 	stPublicKeyFile->Show(false);
 	pickerPublicKeyFile->Show(false);
@@ -238,6 +241,7 @@ void dlgServer::OnOK(wxCommandEvent &ev)
 		server->iSetSSLCompression(chkSSLCompression->GetValue());
 #if defined(HAVE_OPENSSL_CRYPTO) || defined(HAVE_GCRYPT)
 		server->iSetSSHTunnel(chkSSHTunnel->GetValue());
+		server->iSetTunnelPort(StrToLong(txtTunnelPort->GetValue()));
 		server->SetTunnelHost(txtTunnelHost->GetValue());
 		server->SetTunnelUserName(txtTunnelUsername->GetValue());
 		server->iSetAuthModePwd(radioBtnPassword->GetValue());
@@ -281,7 +285,8 @@ void dlgServer::OnOK(wxCommandEvent &ev)
 			    server->GetAuthModePwd(),
 			    server->GetTunnelPassword(),
 			    server->GetPublicKeyFile(),
-			    server->GetIdentityFile());
+			    server->GetIdentityFile(),
+			    server->GetTunnelPort());
 #else
 			    server->GetGroup());
 #endif
@@ -480,6 +485,7 @@ int dlgServer::Go(bool modal)
 			chkStorePwd->SetValue(false);
 			chkStorePwd->Enable(false);
 		}
+		txtTunnelPort->SetValue(NumToStr((long)server->GetTunnelPort()));
 		txtTunnelHost->SetValue(server->GetTunnelHost());
 		txtTunnelUsername->SetValue(server->GetTunnelUserName());
 		if (server->GetAuthModePwd())
@@ -577,7 +583,7 @@ pgObject *dlgServer::CreateObject(pgCollection *collection)
 		                   chkSSHTunnel->GetValue(), txtTunnelHost->GetValue(), txtTunnelUsername->GetValue(),
 		                   radioBtnPassword->GetValue(),
 		                   txtTunnelPassword->GetValue(), pickerPublicKeyFile->GetPath(),
-		                   pickerIdentityFile->GetPath());
+		                   pickerIdentityFile->GetPath(), StrToLong(txtTunnelPort->GetValue()));
 	}
 	else
 #endif
@@ -667,6 +673,7 @@ void dlgServer::CheckChange()
 	if(chkSSHTunnel->GetValue())
 	{
 		CheckValid(enable, !txtTunnelHost->GetValue().IsEmpty(), _("Please specify ssh tunnel host."));
+		CheckValid(enable, !txtTunnelPort->GetValue().IsEmpty(), _("Please specify ssh tunnel port."));
 		CheckValid(enable, !txtTunnelUsername->GetValue().IsEmpty(), _("Please specify ssh tunnel user name."));
 	}
 #endif
@@ -718,6 +725,7 @@ void dlgServer::EnableSSHTunnelControls(const bool &bEnable)
 	radioBtnPassword->Enable(bEnable);
 	radioBtnKeyfile->Enable(bEnable);
 	txtTunnelPassword->Enable(bEnable);
+	txtTunnelPort->Enable(bEnable);
 }
 
 void dlgServer::EnableAuthenticationOptions()
diff --git a/pgadmin/frm/frmMain.cpp b/pgadmin/frm/frmMain.cpp
index 258a7f1..675940a 100644
--- a/pgadmin/frm/frmMain.cpp
+++ b/pgadmin/frm/frmMain.cpp
@@ -1234,6 +1234,7 @@ void frmMain::StoreServers()
 					settings->WriteBool(key + wxT("TunnelModePwd"), server->GetAuthModePwd());
 					settings->Write(key + wxT("PublicKeyFile"), server->GetPublicKeyFile());
 					settings->Write(key + wxT("IdentityFile"), server->GetIdentityFile());
+					settings->WriteInt(key + wxT("TunnelPort"), server->GetTunnelPort());
 #endif
 					pgCollection *coll = browser->FindCollection(databaseFactory, server->GetId());
 					if (coll)
diff --git a/pgadmin/include/schema/pgServer.h b/pgadmin/include/schema/pgServer.h
index 618ffb6..8281391 100644
--- a/pgadmin/include/schema/pgServer.h
+++ b/pgadmin/include/schema/pgServer.h
@@ -35,6 +35,7 @@ protected:
 	int closedId, smallClosedId;
 };
 extern pgServerFactory serverFactory;
+#define DEFAULT_SSH_PORT  22
 
 #if defined(HAVE_OPENSSL_CRYPTO) || defined(HAVE_GCRYPT)
 class CSSHTunnelThread;
@@ -48,7 +49,8 @@ public:
 	         bool storePwd = false, const wxString &newRolename = wxT(""), bool restore = true, int sslMode = 0,
 	         const wxString &colour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW).GetAsString(wxC2S_HTML_SYNTAX), const wxString &group = wxEmptyString,
 	         bool sshTunnel = false, const wxString &newTunnelHost = wxEmptyString, const wxString &newTunnelUserName = wxEmptyString, bool authModePwd = true,
-	         const wxString &newTunnelPassword = wxEmptyString, const wxString &newPublicKey = wxEmptyString, const wxString &newIdentityFile = wxEmptyString);
+	         const wxString &newTunnelPassword = wxEmptyString, const wxString &newPublicKey = wxEmptyString, const wxString &newIdentityFile = wxEmptyString,
+	         const int &sshPort = DEFAULT_SSH_PORT);
 	~pgServer();
 	int GetIconId();
 
@@ -513,6 +515,14 @@ public:
 	{
 		identityFile = s;
 	}
+	int GetTunnelPort() const
+	{
+		return tunnelPort;
+	}
+	void iSetTunnelPort(const int newval)
+	{
+		tunnelPort = newval;
+	}
 #endif
 
 	void ShowDependencies(frmMain *form, ctlListView *Dependencies, const wxString &where = wxEmptyString);
@@ -550,6 +560,7 @@ private:
 	CSSHTunnelThread *tunnelObj;
 	bool authModePwd;
 	int local_listenport;
+	int tunnelPort;
 	wxString tunnelHost, tunnelUserName, tunnelPassword, publicKeyFile, identityFile, local_listenhost;
 #endif
 
diff --git a/pgadmin/include/utils/sshTunnel.h b/pgadmin/include/utils/sshTunnel.h
index b06ff14..e8b2b29 100644
--- a/pgadmin/include/utils/sshTunnel.h
+++ b/pgadmin/include/utils/sshTunnel.h
@@ -57,7 +57,7 @@ class CSSHTunnelThread :
 public:
 	CSSHTunnelThread(const wxString tunnelhost, const wxString remote_desthost, const unsigned int remote_destport,
 	                 const wxString username, const wxString password, const wxString publickey, const wxString privatekey,
-	                 const enAuthenticationMethod &enAuthMethod);
+	                 const enAuthenticationMethod &enAuthMethod, const unsigned int tunnelPort = 22);
 	virtual ~CSSHTunnelThread(void);
 	virtual void *Entry();
 	bool Initialize();
@@ -94,6 +94,7 @@ private:
 	wxString m_remote_desthost;
 	unsigned int m_local_listenport;
 	unsigned int m_remote_destport;
+	unsigned int m_tunnelPort;
 	enAuthenticationMethod m_enAuthMethod;
 };
 
diff --git a/pgadmin/schema/pgServer.cpp b/pgadmin/schema/pgServer.cpp
index a71d111..2f507b6 100644
--- a/pgadmin/schema/pgServer.cpp
+++ b/pgadmin/schema/pgServer.cpp
@@ -47,7 +47,7 @@
 pgServer::pgServer(const wxString &newName, const wxString &newHostAddr, const wxString &newDescription, const wxString &newService,
                    const wxString &newDatabase, const wxString &newUsername, int newPort, bool _storePwd, const wxString &newRolename, bool _restore,
                    int _ssl, const wxString &_colour, const wxString &_group, bool _sshTunnel, const wxString &newTunnelHost, const wxString &newTunnelUserName,
-                   bool _authModePwd, const wxString &newTunnelPassword, const wxString &newPublicKey, const wxString &newIdentity)
+                   bool _authModePwd, const wxString &newTunnelPassword, const wxString &newPublicKey, const wxString &newIdentity, const int &sshPort)
 	: pgObject(serverFactory, newName)
 {
 	description = newDescription;
@@ -83,6 +83,7 @@ pgServer::pgServer(const wxString &newName, const wxString &newHostAddr, const w
 	tunnelPassword = newTunnelPassword;
 	publicKeyFile = newPublicKey;
 	identityFile = newIdentity;
+	tunnelPort = sshPort;
 #endif
 
 #ifdef WIN32
@@ -1249,7 +1250,7 @@ bool pgServer::createSSHTunnel()
 	bool retVal = false;
 
 	tunnelObj = new CSSHTunnelThread(tunnelHost, GetName(), port, tunnelUserName, tunnelPassword, publicKeyFile,
-	                                 identityFile, authModePwd ? AUTH_PASSWORD : AUTH_PUBLICKEY);
+	                                 identityFile, authModePwd ? AUTH_PASSWORD : AUTH_PUBLICKEY, tunnelPort);
 
 	if(tunnelObj)
 	{
@@ -1471,6 +1472,7 @@ pgObject *pgServerFactory::CreateObjects(pgCollection *obj, ctlTree *browser, co
 
 #if defined(HAVE_OPENSSL_CRYPTO) || defined(HAVE_GCRYPT)
 	wxString sshTunnel, authModePwd, tunnelHost, tunnelUserName, tunnelPassword, publicKeyFile, identityFile;
+	long tunnelPort;
 #endif
 	pgServer *server = 0;
 
@@ -1517,6 +1519,7 @@ pgObject *pgServerFactory::CreateObjects(pgCollection *obj, ctlTree *browser, co
 		settings->Read(key + wxT("TunnelModePwd"), &authModePwd, wxT("true"));
 		settings->Read(key + wxT("PublicKeyFile"), &publicKeyFile, wxEmptyString);
 		settings->Read(key + wxT("IdentityFile"), &identityFile, wxEmptyString);
+		settings->Read(key + wxT("TunnelPort"), &tunnelPort, DEFAULT_SSH_PORT);
 #endif
 		// Sanitize the colour
 		colour = colour.Trim();
@@ -1553,7 +1556,7 @@ pgObject *pgServerFactory::CreateObjects(pgCollection *obj, ctlTree *browser, co
 		// Add the Server node
 #if defined(HAVE_OPENSSL_CRYPTO) || defined(HAVE_GCRYPT)
 		server = new pgServer(servername, hostaddr, description, service, database, username, port, StrToBool(storePwd), rolename, StrToBool(restore), ssl,
-		                      colour, group, StrToBool(sshTunnel), tunnelHost, tunnelUserName, StrToBool(authModePwd), tunnelPassword, publicKeyFile, identityFile);
+			colour, group, StrToBool(sshTunnel), tunnelHost, tunnelUserName, StrToBool(authModePwd), tunnelPassword, publicKeyFile, identityFile, tunnelPort);
 #else
 		server = new pgServer(servername, hostaddr, description, service, database, username, port, StrToBool(storePwd), rolename, StrToBool(restore), ssl,
 		                      colour, group);
diff --git a/pgadmin/ui/dlgServer.xrc b/pgadmin/ui/dlgServer.xrc
index 4d03436..ddf3438 100644
--- a/pgadmin/ui/dlgServer.xrc
+++ b/pgadmin/ui/dlgServer.xrc
@@ -296,6 +296,18 @@
                   <border>4</border>
                 </object>
                 <object class="sizeritem">
+                  <object class="wxStaticText" name="stTunnelPort">
+                    <label>Tunnel Port</label>
+                  </object>
+                  <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxTextCtrl" name="txtTunnelPort"/>
+                  <flag>wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
                   <object class="wxStaticText" name="stTunnelUsername">
                     <label>Username</label>
                   </object>
diff --git a/pgadmin/utils/sshTunnel.cpp b/pgadmin/utils/sshTunnel.cpp
index ec917f1..8d15cd2 100644
--- a/pgadmin/utils/sshTunnel.cpp
+++ b/pgadmin/utils/sshTunnel.cpp
@@ -50,9 +50,9 @@ char CSSHTunnelThread::m_keyboard_interactive_pwd[SSH_MAX_PASSWORD_LEN];
 
 CSSHTunnelThread::CSSHTunnelThread(const wxString tunnelhost, const wxString remote_desthost, const unsigned int remote_destport,
                                    const wxString username, const wxString password, const wxString publickey, const wxString privatekey,
-                                   const enAuthenticationMethod &enAuthMethod)
+                                   const enAuthenticationMethod &enAuthMethod, const unsigned int tunnelPort)
 	: m_tunnelhost(tunnelhost), m_remote_desthost(remote_desthost), m_remote_destport(remote_destport), m_username(username),
-	  m_password(password), m_publickey(publickey), m_privatekey(privatekey), m_enAuthMethod(enAuthMethod)
+	  m_password(password), m_publickey(publickey), m_privatekey(privatekey), m_enAuthMethod(enAuthMethod), m_tunnelPort(tunnelPort)
 {
 	m_local_listenip = wxEmptyString;
 	m_local_listenport = 0;
@@ -108,7 +108,7 @@ bool CSSHTunnelThread::Initialize()
 			LogSSHTunnelErrors(wxString::Format(_("SSH error: Error in inet address with error code %d"), wxSysErrorCode()), GetId());
 			return false;
 		}
-		m_sin.sin_port = htons(22);
+		m_sin.sin_port = htons(m_tunnelPort);
 		if (connect(m_sock, (struct sockaddr *)(&m_sin),
 		            sizeof(struct sockaddr_in)) != 0)
 		{
