How to send a right click or paste command in ssh

How to send a right click or paste command in ssh

avatar

I'm looking for a way to paste clipboard contents in SSH either via macro, event or post login command. Any ideas?

All Comments (7)

avatar

Hello,

We've added this feature back in 2025.3, could you try using the {CLIPBOARD} command in your macro/post-login command and see if it works?

Regards,

Hubert Mireault

avatar

Hubert,
I didn't see any documentation on that. Can you give me the exact syntax for using it, assuming the password is xxxx?

Can it be used in the "Events" section specifically to paste a password in the clipboard in after logging into a secondary server?

Thanks,
Brad

avatar

Hello,

If you simply enter {CLIPBOARD} as part of your macro string, it should paste your clipboard when it parses this command.
So for example if you have the following string:

sudo{CLIPBOARD}{ENTER}


It should enter the string "sudo", paste your clipboard, and then press the enter key. So provided you've put your password in your clipboard, it should paste your password as part of your command.

Regards,

Hubert Mireault

avatar

Does anything need to be "turned on" first? If not, it's not working.
I'm trying to set up a system where I can log into a bastion server, and then from there automatically log in to several other servers in sequence, run a couple commands in each, log out of each and move on to the next. ideally this would be done by running one macro after logging into bastion. I'm not able to store any "keys" on the remote servers, and I'm not able to find a way to enter the passwords (which are the same for each remote server) automatically. Was hoping having that password in the clipboard and using this feature would work, but following your instructions it hangs at the password prompt. See pics.


Apologies for the redactions. It is clear it's doing "something" at the first password prompt. I did make sure the correct password was in the clipboard at the time.

I've tried the same procedure as "events" with the same result. I also tried first manually logging into bastion and then running a typing macro with the commands. Same result. Any ideas? There's gotta be a way to enter a password automatically in an SSH script, right?

3d7a096c-253e-4708-bdb8-039059e621f7.png

e802eb9d-56bb-4663-af8d-f39dc2b19800.png

avatar

Hello,

One small note, I mistyped in my original comment and meant sudo{ENTER}{CLIPBOARD} rather than sudo{CLIPBOARD}{ENTER}. But, there's another issue here. Looking at your screenshots, I think you're missing one password prompt. From what I understand, it's doing the following:

  • RDM connects to the remote host
  • The first macro is sent: ssh yourhost.com
  • The first macro triggers the password being required
  • The second macro is sent: sudo{CLIPBOARD}{ENTER}
  • This second macro is fully sent as part of the password being required, so it sends "sudo<Your clipboard>" and presses the enter key.


Is the password meant to be the same password as in your sudo command? if that's the case, then the full chain of macros you would need would be the following:

  • ssh yourhost.com
  • {CLIPBOARD}
  • sudo{ENTER}{CLIPBOARD}


This would ssh into your second host, trigger the password prompt, send the clipboard for the password prompt, then do the sudo command, press the enter key, and enter your clipboard again.
You technically don't need to add {ENTER} at the end of your commands if you have "Automatic {ENTER} after command" checked, which you do in your screenshot.

Additionally, if you need a command to only be sent when the terminal prompts for a certain value, you can use the "expected prompt" parameter. This could help ensure you only send your clipboard when the password prompt is actually asked. It will do a string match to ensure it only sends the command when the terminal shows that string.

Regards,

Hubert Mireault

avatar

Still not there...when I add the extra {clipboard} line, it goes faster, and doesn't have the open space, but still it comes up with permission denied and once again asking for the password.

To try to clarify - the post login you're seeing is after I've logged into bastion server successfully. When the script runs, it contacts "ssh yourhost.com", and then prompts for the password. I can see the "macro running" icon pop up in lower right, and then it gives permission denied.

For the expected prompt - should that be on the line with the server address or the line with the {clipboard}? Or the 3rd line? Or multiple lines?

I feel like we're close here. :)

avatar

Hello Brad,

I believe we are close, but at this point it would probably be more efficient to review this together in a short support session rather than continuing through multiple forum replies.

I will send you a session link by email. A quick 15-minute session should help us validate the macro behavior, confirm where the password prompt is being detected, and adjust the expected prompt configuration if needed.

Best regards,

Carl Marien