0

I want to create a shell script, that automates the login procedure with my terminal to my university servers. the official procedure is: use ssh to login into a login-server of the Uni. From the login-server, use ssh to a PC-pool computer -> do your stuff there. You are not allowed to do any "heavy" computing on the login servers.

When using just my terminal, the command series is:

user@home:ssh -X user@loginServer.uni.de
#here i am being asked for my password
user@loginServer:ssh -X pcName
#no password req. here
user@pcName:cd Documents
#exemple one command to execute.

Right now, i have created a small script, that just does the first two steps: logging in to both servers and providing a terminal to me (but without using the -X option, so I can't start programs with a GUI).

#!/usr/bin/bash
sshpass -p 'user' ssh -t user@loginServer.uni.de "ssh user@pcName"

But now I'd like to also execute some basic commands on the second pc, like moving into a directory and still having the terminal after that to further work on the pc, and hopefully be able to start programs with User interfaces..

And yes, I know it's not secure to safe your password in plain text in a script. I am quite a noob with such scripts and do this more as a feasibility study than as an important routine.

Moritz
  • 27
  • 1
  • 6
  • To bad I can't comment yet, but you might want to look at https://stackoverflow.com/questions/2823007/ssh-login-with-expect1-how-to-exit-expect-and-remain-in-ssh – warkruid Apr 07 '22 at 17:55

0 Answers0