LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-27-2023, 08:05 AM   #1
GenericLinuxUser
LQ Newbie
 
Registered: Mar 2012
Posts: 11

Rep: Reputation: Disabled
Is there anyway to run a remote command via ssh as if it's run from the local server?


Hi,

I am working on setting up an LDAP connection on a server. On the server I want to use ldapsearch for testing but it's not installed. I do have access to ldapsearch installed on another server. However, the AD server is only seen from the server that does not have ldapsearch installed. I've asked our sysadmins to install ldapsearch on the needed server but there's a bureaucratic hold up and I'm trying to see if I can somehow run the remote command as if I'm on the server and just get this done.

In other words, I can see an AD server (XXX) from server YYY

myuser@YYY: ping -c 1 XXX
PING XXX (xxx.xxx.xxx.xxx) 56(84) bytes of data.
64 bytes from XXX (xxx.xxx.xxx.xxx): icmp_seq=1 ttl=121 time=32.6 ms
--- XXX ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 32ms


I can't from ZZZ

myuser@ZZZ: ping -c 1 XXX
ping: XXX: Name or service not known


I can run ldapsearch from server ZZZ on server YYY via ssh

myuser@YYY: ssh myuser@ZZZ ldapsearch -x -h XXX -p 389 -D "CN=myuser,CN=users,DC=example,DC=Com" -W -b "DC=example,DC=Com" cn=myuser


But this of course returns "Can't contact LDAP server" because ZZZ does not know of XXX. Is there anyway to run a remote command via ssh as if it's run from the local server?

Last edited by GenericLinuxUser; 03-27-2023 at 08:15 AM.
 
Old 03-27-2023, 08:33 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,306
Blog Entries: 3

Rep: Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720
You could try a reverse tunnel to forward the LDAP port and then connect to the LDAP port on the address for localhost on the remote system.
 
1 members found this post helpful.
Old 03-27-2023, 09:03 AM   #3
GenericLinuxUser
LQ Newbie
 
Registered: Mar 2012
Posts: 11

Original Poster
Rep: Reputation: Disabled
Thanks Turbocapitalist, reverse tunneling seems promising, I'll look into that
 
Old 03-27-2023, 10:55 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
you just need to run the command on ZZZ: ssh myuser@YYY ldapsearch ....
 
1 members found this post helpful.
Old 03-27-2023, 01:24 PM   #5
GenericLinuxUser
LQ Newbie
 
Registered: Mar 2012
Posts: 11

Original Poster
Rep: Reputation: Disabled
pan64, if I do that I get "bash: ldapsearch: command not found" because ldapsearch is not installed on YYY
 
Old 03-27-2023, 01:52 PM   #6
yvesjv
Member
 
Registered: Sep 2015
Location: Australia
Distribution: Slackware, Devuan, Freebsd
Posts: 564

Rep: Reputation: Disabled
Also copy the certs for making life a bit easier
https://www.thegeekstuff.com/2008/11...n-ssh-copy-id/
 
  


Reply

Tags
ssh



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Local Script On Remote System via SSH nikolaymartin Linux - Software 4 05-07-2020 08:39 AM
Work on a remote project with Eclipse via SSH and SVN+SSH (2 remote Linux) alwaystudent Linux - Software 5 08-12-2015 11:40 AM
Is there anyway to copy a file on a remote desktop to my hard drive? Mark_S Linux - Newbie 9 07-29-2015 08:59 AM
[SOLVED] SSH remote command: Pipe remote output to local machine? kenneho Linux - Server 6 12-06-2012 01:37 AM
Is there anyway to execute bash as interactive and run a command? nfirvine Linux - Software 6 06-23-2009 11:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration