Login shell script
This is the first time I have posted here so forgive me if this is not the correct place to post a question like this.
If I wanted a script to launch every time I SSH/logged into a server, where would I put it?
Here's the scenario:
Server1 - On secured network1, accessible by Server2 & Server3; not accessible by Workstation1
Server2 - On secured network1, accessible by Server1 & Server3; not accessible by Workstation1
Server3 - On secured network2, accessible by Server1, Server2 & Workstation1
Workstation1 - On unsecured network3
Server1 & Server2 are my destination servers, via SSH, from Workstation1. However, I have to use Server3 to get to Server1 & Server2; Server3 is kind of like a jump server to get from Workstation1. Every time I SSH to Server3, I would like the login script to launch. What I plan on putting in this script is the option to ask me, as soon as I login, if I I want to connect (SSH) to one of the servers and, depending on my reply, I would then either not SSH to one of the servers and just continue working on Server3 or SSH to one of the servers that I choose.
Thanks.
Responses
To answer your question simply, you would use (as you discovered) ~/.bash_profile (or .bashrc) as the latter is actually included by the former.
In a former job I had created a pretty sweet setup similar to what you might be looking for (unfortunately I did not bring the profile files with me so I can't give you exact code). But basically I configured [password-protected] SSH keys between the hosts. They were password protected. I set it up so that .bash_profile called ssh-agent which prompted me for my SSH key password and then loaded the key into the session. After that I would launch screen and automatically open a connection to each of my backend servers (in your case server1 and server2) in a separate window within screen.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
