0

I am planning to have a program that will need to connect to a server. I'd like to be able to send a encrypted password to my server. The thing is, I need my decrypting script to be executed (everytime I need to login, not only at boot) before login in.

Is that possible?

  • 2
    Would executing the script as part of the login process work? You can add scripts that execute on login to /etc/profile (for all users) or ~./profile if you're logging in at the console. There are many variations though. Are you logging in to a GUI or at the console? Do you want to script to execute if you connect remotely to your box (e.g. via ssh)? If at the console, you probably want to check out man bash and read the INVOCATION section. – bobstro Jul 26 '15 at 20:33
  • 1
    If bobstro's suggestion does not lead you to a solution and you legitimately want help, you need to come up with a more detailed description of what you want to do. Right now, particularly in light of your other question, this just reeks of XY problem and many people who likely could help you will not be bothered to because of that. – goldilocks Jul 26 '15 at 21:05
  • also asked on U&L – hildred Jul 27 '15 at 3:29
  • Related to: raspberrypi.stackexchange.com/questions/8734/… – Elber CM Mar 4 '16 at 15:02
1

If you would like to execute this script every time a user login at your ssh server. You can place a script at /etc/ssh/sshrc the sshrc will automatically triggered when any user login into the server successfully.

This script is globally for all users they will login on the server. Also SFTP users, SSHFS users and all others they connect to your ssh-server.

We are using this feature to trigger a Slack Hook, to notify our team. For example you are able to get the ip-address of the person they would like login into our server.

| improve this answer | |
0

I don't know if it is what you want, but if you use always the bash as the default shell, you can add your script in ~/.bashrc and it will execute every time bash is executed (all logins). The bad side is that if you execute a simple $ bash order, the script will execute also.

| improve this answer | |
0

Edit /etc/rc.local and add the command you wish to run at the end of the script. Don't modify the already existing commands in the script however, as this is what sets up networking on boot.

| improve this answer | |
  • 2
    The question explicitly says , "I need my decrypting script to be executed (everytime I need to login, not only at boot)". This will not do that. – goldilocks Jul 26 '15 at 18:16
0

Add your script in /etc/rc.local to execute on boot
Add your script in crontab with the @reboot prefix to execute on boot, too
Add your script at then of the file ~/.bashrc to execute AFTER login

Using ~/.bashrc will execute your script after you login, also if you log from SSH.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.