Accessing Internal Server from Outside through SSH

1,428

Solution 1

Here is the solution: http://www.spencerstirling.com/computergeek/sshtunnel.html

It is doing SSH tunneling with forwarding through a gateway. For the above scenario, you need to issue the following command:

ssh -N -L 5555:X:5432 user@Y

Where X is the name of the database server used to address it from Y. 5555 is just some arbitrary port not being used on your home machine and 5432 is the port on which the PostgreSQL database server on X is listening. When you issue this command, you will be asked for a password, this is the one you use for logging into Y.

The PostgreSQL client (pgAdmin for example) is configured as follows: host: localhost port: 5555 username: the database username password: the database password

Solution 2

You can do a reverse ssh tunnel to puncture a hole through the corp firewall. Do this from within the company:

ssh -nNT -R 5000:localmachinename:22 [email protected]

When you're logged in you can connect from home by doing:

ssh -p5000 localhost
Share:
1,428

Related videos on Youtube

Elaine K
Author by

Elaine K

Updated on September 17, 2022

Comments

  • Elaine K
    Elaine K over 1 year

    Hi and thanks in advance.

    I have a gridview that has four columns. The fourth column is hidden or displayed based on a set of criteria which is working correctly. But when the table displays, the very first cell in that last column is not showing any text, even though on databound it clearly shows that it has the text. So the gridview winds up showing data like this:

       Name         Address           Zip Code
     X H. Smith     123 Raton Ave. 
     X A. Rally     345 6th St        98453
     X B. Holcomb   876 Harrison Blvd 56321
    

    The OnRowDataBound looks like this:

    protected void gvAddresses_OnRowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //This test evaluation string showed the correct data for every row
            //string myvalue = DataBinder.Eval(e.Row.DataItem, "ZipCode").ToString();
            if (user.State == (int)States.California) 
                gvAddresses.Columns[3].Visible = true;
    
        }
    }
    

    There doesn't seem to be any problem with the binding and when I debug through the gridview each row is processed as I would expect. Here is the gridview:

     <asp:GridView runat="server" ID="gvAddresses" CssClass="TableFormat gvMargin"       Width="100%" AutoGenerateColumns="false" 
          OnRowCommand="gvAddresses_OnRowCommand" OnRowDeleting="gvAddresses_OnRowDeleting" OnRowDataBound="gvAddresses_OnRowDataBound">
          <EmptyDataTemplate>
               <div style="text-align: center;">No addresses available.</div>
          </EmptyDataTemplate>
          <Columns>
          <asp:TemplateField HeaderText="" ItemStyle-HorizontalAlign="Center">
               <ItemTemplate>
                     <asp:LinkButton ID="lnkRemoveAddress" runat="server" OnClientClick="if(!confirm('Are you sure you want to delete this record?')) return ;"  style="color: maroon; font-weight: bold;" Text="X" CommandName="Delete" CommandArgument='<%# Eval("AddressCode") %>'></asp:LinkButton>
               </ItemTemplate>
          </asp:TemplateField>
          <asp:BoundField DataField="Name" HeaderText="Name" />
          <asp:BoundField DataField="Address" HeaderText="Address" />
          <asp:BoundField DataField="ZipCode" HeaderText="Zip Code" Visible="False"/>
          </Columns>
      </asp:GridView>
    

    How else can I discover what is happening to this first cell?

    • Dropzilla
      Dropzilla about 10 years
      Have you checked the DOM using web tools in ie or inspector in chrome to see if the data exist but maybe the cell is still hidden?
  • Elaine K
    Elaine K about 10 years
    Thank you, I'm still not certain why the visisble=false causes the issues since all the others show but that was the problem. I did move column hiding out of the databound also. :)
  • Adam Heeg
    Adam Heeg about 10 years
    Here is what I believe was happening. Your page rendered and that entire last column was set to be not visible. On the first databind your grid was still set to visible = false until after asp.net renedered your markup. After that first row databind the column was set to visible, and on the next postback the column was finally rendered and available. I also think the child controls inherited the visible = false, but I am not 100% sure.