Embedding code into ssh keys


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Embedding code into ssh keys
# 1  
Old 08-01-2012
Embedding code into ssh keys

Hi

Its been a long time since I worked with ssh keys containing embedded shell commands and cannot remember how it is done.

Does anyone know of any sites that have a good tutorial on the subject? I'm not having much luck searching Google for it.

Incidentally, searching this forum for the keyword ssh returns -

Quote:
The following errors occurred with your search:
Array
Thanks in advance

Brad
# 2  
Old 08-01-2012
Could you clarify what exactly are you trying to do here? Not the method, but the goal?
# 3  
Old 08-02-2012
Clarification

Hi

Thanks for responding.

I remember that I used to use a code deployment mechanism that had to be locked down and secure. The way it had been implemented was that code would be delivered via ssh using a specific key and user. Embedded within the key was some code, korn shell as I recal and a call to a C program.

The shell commands basically deleted the directory structure and then untarred the new deployment in its place.

The idea was that as the permissions on the entire repo were only read and execute, nobody could hijack it to do anything malicious.

I now have a requirement to implement something similar, but I can't remember how the code was added to the key and I seem to be struggling to come up with a good search term for google to find examples.

Cheers

Steady
# 4  
Old 08-02-2012
To force a command, you insert into authorized_keys like this:

Code:
command="/path/to/script",no-port-forwarding,no-X11-forwarding ssh-rsa ...

These 2 Users Gave Thanks to neutronscott For This Post:
# 5  
Old 08-02-2012
Not quite

Thanks

That's got me looking at a whole bunch of stuff.

It's not what I was talking about though.

I remember picking the code out of the key itself and reading through it. About the only thing I do remember about it was that it was { between; }.

The command= syntax substitutes whatever command is passed via ssh.

Not the same thing.

I'll keep digging Smilie
# 6  
Old 08-02-2012
it's very likely shell code was placed directly in the command="" then. it replaces the clients requested command in that the client no longer has any choice of what is ran. it sounds like exactly what you were describing.
These 2 Users Gave Thanks to neutronscott For This Post:
# 7  
Old 08-03-2012
I guess you're right

Come to think of it, the key was dedicated to the task of deploying the code. So I guess that was it.

Thanks for the help Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find active SSH servers w/ ssh keys on LAN

Hi, I am trying to complete my bash script in order to find which SSH servers on LAN are still active with the ssh keys, but i am frozen at this step: #!/bin/bash # LAN SSH KEYS DISCOVERY SCRIPT </etc/passwd \ grep /bin/bash | cut -d: -f6 | sudo xargs -i -- sh -c ' && cat... (11 Replies)
Discussion started by: syrius
11 Replies

2. Red Hat

Configuring the SSH keys..

I am currently working on setting up a server to scp some files over for backup purposes. Server 1 - Bob (Appliance) Server 2 - Sana (RH 5) Server 1 - 1 - Generated RSA2 2 - Collected the public key to be input on the backup server = Sana Server 2 - 1 - This is were I am stuck the... (4 Replies)
Discussion started by: NelsonC
4 Replies

3. Solaris

help with SSH keys

Hello, I could use some help with my ssh keys and agent. This is the issue. I have 2 different UNIX systems at work. One is the normal Solaris servers with my uid being the same throughout all the servers. I now have a different system for my desktop. A contractor came in and installed some SUN... (0 Replies)
Discussion started by: bitlord
0 Replies

4. Red Hat

SSH keys are not working

Hi, I've generated and posted pub. keys in the source system and the target. However, it is still prompting me for the password. Steps that I have taken. 1. Generated ssh keys : ssh-keygen. It created two files. 1. .ssh/id_rsa 2. .ssh/id_rsa.pub. 2.... (10 Replies)
Discussion started by: Afi_Linux
10 Replies

5. Shell Programming and Scripting

What are public keys in ssh and how do we create the public keys??

Hi All, I am having knowledge on some basics of ssh and wanted to know what are the public keys and how can we create and implement it in connecting server. Please provide the information for the above, it would be helpful for me. Thanks, Ravindra (1 Reply)
Discussion started by: ravi3cha
1 Replies

6. Shell Programming and Scripting

Embedding a command with SSH

Hi I am trying to run a script centrally that will go out and set the network management ip address on all my Sun boxes running Solaris. We have decided that the network management address will be the boxes main IP address but the first octet as a 172 rather than a 10, so for example ifconfig -a... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

7. Programming

Embedding xnest in C code

I hope I am posting this in the right section. I have c file that is using the motif GUI toolkit to draw widgets and things of that sort. I also have another program that runs with xnest. I need to figure out a way to place that xnest program in my c code so that it exists in the window that the... (4 Replies)
Discussion started by: lesnaubr
4 Replies

8. UNIX for Dummies Questions & Answers

SSH keys

Hi everyone, i wanted to generate ssh keys so that i can include the public key in the remote sever, so that for subsequent logins, i can do away with the keying in of the password. I consulted the man ssh-keygen man pages. "..Normally each user wishing to use SSH with RSA or DSA... (1 Reply)
Discussion started by: new2ss
1 Replies

9. UNIX for Advanced & Expert Users

SSH Keys Help

Hello, I'm wondering if anyone has a step-by-step instruction set for setting up ssh keys? I've gone through many of the manuals online (most seem to be from the same source) and it's a little bit unclear when the documentation is talking about the server versus the client machine. I'm missing... (1 Reply)
Discussion started by: sysera
1 Replies
Login or Register to Ask a Question