开发者

Best way to make a script to SSH?

My university has quite a lot files (like past papers etc) which I need to be on the uni network to access them. I ssh, using port forwarding, into the network and set my browser (Firefox) to go through that port. I know it would be quite easy to write something in most languages that would enter the command into a terminal, but which language/method could I use to make this happen? I expect some sort of scripting language could but I really know nothing about them, but I'd be willing to learn one just to have a little fun with this.

I'm using a cygwin terminal on Windows 7, if that will make a difference.

To neaten up my question: Which language would be best to acheive the above effect? Not necessarily the best, just possible and relatively simple to learn. I used the word best so I suppose I'll put a subjective tag.

EDIT: Just in case anyway wants to do this precise thing, I'll show my solution. I ended up using a batch file because a few things made the bash more difficult. Anyway, in order to SSH into the network and open a new firefox window with the proxy changed, I just have to open this batch file and enter my password.

cd C:/cygwin/bin
ssh -fND 9001 username@your.website.here
cd "C:/Program Files/Mozilla Firefox"
firefox -no-remote -P SSH_profile

Save as .bat

In order for this to work you need to set up a profile with name SSH_profile (or whatever) and set the connection settings to go through port 9001. The script will open use the开发者_开发知识库 ssh command in /cygwin/bin and enter in the information. You enter your password and then it goes to your firefox directory, uses those arguments which opens a separate profile with the connection settings changed (means you can view unaccessible files in one window and anything else you don't want to be on your uni network in another. Just close the windows when you are done.

Quite a specific case but I thought I'd share my answer in the hope of helping someone, some day.


Since you are using cygwin, write a bash shell script.. If you don't want to rely on bash, powershell would be what you want, although you could probably get it working using a batch file.

This is exactly the kind of thing shell scripting is for.

Edit

You can change the firefox settings on the command line by passing the -override flag. This will let you have special settings for the invoked process.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜