Execute commands on remote server behind another server (jumphost) using Plink
Better solution is using Plink's -proxycmd
:
plink -ssh anotherIP -pw passwordForAnotherIP -no-antispoof -proxycmd "plink -ssh hostname@ipaddress -pw password -nc anotherIP:22" -m C:\commands.txt
With the commands.txt
containing only the:
cd /tmp
cat filename
To answer your literal question:
The OpenSSH ssh
has no -pw
switch. See Automatically enter SSH password with script.
Additionally, your command.txt
won't do what you think anyway. It won't run the cd
and cat
within the ssh
. It would run them after the ssh
. So on the ipaddress
. How to do this properly is discussed in: Entering password to remote ssh through Plink after establishing a connection.
How can I connect to Oracle Database 11g server through ssh tunnel chain (double tunnel, server in company network)?
Yes, it's possible. E.g. on Linux, run
ssh -N -Llocalport:dbserver:dbport yourname@connectionserver
where
- localport is the port on your machine which will be forwarded (can be 1521 if there is no local instance of oracle running)
- dbserver is the name or IP of the database server
- dbport is the port of the database (usually 1521)
- yourname is the login on the connectionserver
- connectionserver is the machine where you have ssh access
The same can be done on Windows using Plink (which comes with Putty):
plink -N -L localport:dbserver:dbport yourname@connectionserver
Do this on both machines (your local machine and the server you have access to) to chain the ssh tunnels. Example:
Connection server (assuming Linux):
ssh -N -L1521:dbserver:1521 dblogin@dbserver
Your PC:
plink -N -L 1521:connectionserver:1521 connlogin@connectionserver
The tnsnames.ora entry must look like you are running a local database, e.g.
prodoverssh =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = prod)
)
)
Related Topics
How to Limit the Results on a SQL Query
Sql: Join Tables on Substrings
How to Format Datetime as M/D/Yyyy in SQL Server
How to Use a Function-Based Index on a Column That Contains Nulls in Oracle 10+
Calling a Stored Procedure Within a Stored Procedure
T-SQL Looping Through Xml Data Column to Derive Unique Set of Paths
What Is the Correct Syntax for Using Database.Executesqlcommand with Parameters
How to Compare If Two Strings Contain the Same Words in T-SQL for SQL Server 2008
What Is the Affect of Convert() on Index While Searching
Join Versus Exists Performance
SQL How to Search a Many to Many Relationship
How to Make a Column Invisible in an Ssrs Matrix
Connect to Remote SQL Database Using Excel
Select Query Does Not Work When Converted to Vba - Invalid SQL Statement