Hi, I've just been trying to setup so that server1 can ssh into server2 and execute a limited set of commands only without password login. I want it also to be able to login with a password if no command given at all though (bit I'm stuck on).
I have got this almost working with authorized_keys and
from="hostofserver1",command="/pathtocomandstocheck.sh" rest of key> in authorized_keys file.
This all works fine, so I can "ssh server2 ls" and all works fine (as I have allowed ls in the script). If I enter a wrong command it doesn't do anything and kicks me out. So far so good.
Only problem is that with that key/entry in place, I can no longer login to the box normally if wanted with a normal password.
So I want to be able to "ssh server1 ls" checks keys and it works, no password needed. Or just "ssh server1" and it asks for a password, and assuming correct gives me a shell.
I don't believe this will work quite how you want it too.
By using the command option, you are limiting that key to the specified commands, including the shell. To allow it you would need to add the shell to the command but that makes what you are trying to achieve pointless.
Here is what I would do:
Keep the key you have now, and use that like you have been. Create a second identity file with a second key.
Do not allow add it authorized_keys on the remote host and launch it like this:
It should prompt for a password as normal. You could create a wrapper alias to save having to type the path to the identity file.
Please note this is untested, and there are probably better ways to do it. I have made a few assumptions (like it seems everyone connects to this system with the same account?).
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:
# LAN SSH KEYS DISCOVERY SCRIPT
grep /bin/bash |
cut -d: -f6 |
sudo xargs -i -- sh -c '
&& cat... (11 Replies)
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)
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)
I work in an environment, where I need to login to multiple UNIX sessions(Always types my password when prompted for)
I heard of ssh keys which provides us a valid authentication and that avoids us typing the password.
Now I want to generate the ssh keys and use in my... (2 Replies)
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.
Ravindra (1 Reply)
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)
Hello*! I have problems with public keys. On one side i have Solaris 10, and on other side is HP UNIX. I created public keys on Solaris with "ssh-keygen -t rsa", append id_rsa.pub key to ~user/.ssh/authorized_keys on remote machine, and tried to connect with ssh without password. But for some... (1 Reply)
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)
hey guys im rly new to unix. im attempting to list the 5 largest files in a directory.
so i got this far...
ls -lR | sort -r
and this lists all files by filesize, how can i limit this to only the 5 largest? (4 Replies)