Another shell open when at server? - bash

How can I have another Terminal open when I am at my server by ssh?
I do not want to type my password twice to get another terminal for my server.
Perhaps, Bash has buffers similarly as Vim.

Check out GNU screen. It's kind of arcane and awkward to use, but does what you're looking for, and it's probably also installed on your server.
You can also forward X11 and run multiple xterm instances, but that's a pain.
Your best bet, though, is your proverbial "type my password every time" solution: you should set up SSH keys so you don't need to type your password every time and then just use multiple connections in Terminal tabs.

You can use something like GNU Screen.

The Bash shell has a feature called Job Control that allows you to run and manage multiple processes. You can read about it here: http://commandlinemac.blogspot.com/2008/12/bash-job-control-fg-bg-jobs-and-ctrl-z.html

GNU Screen
BTW. If you don't like typing passwords, try PK auth.
How it's done with PuTTy.

It's possible to use screen to open other terminals without needing to authenticate again.
Screen can also detach so that you can leave terminal open after logging out and re-attach them later. I use this on my home server for keeping rtorrent open.

Related

Different shell for tty and SSH sessions for a single user

I use the zsh on a daily basis, and I really like its fancy prompts one can choose. And I am managing a simple Linux server, usually through ssh.
However, I sometimes need to be there locally to manually configure some stuff (things like initial installation, firewall configuration, etc), rather than through ssh. And in those cases I have to use the tty, as we have no GUI enabled (runlevel 3). The TTY does not seem to like powerline fonts, colors, and such. So I would be happy if I could just login directly to bash rather than zsh in those cases, but I am not sure how to implement it without wreaking havoc. Maybe a conditional in a file such as .profile? Or should it be somewhere else?
Needless to say, this should happen at the user level (the rest of the users are fine with bash anyway).
thanks in advance

Osx - users and GUI

My question is very simple.
How does OSX understands that this special process needs to make output to special terminal? Can we change it?
For example, is it possible to run process via ssh connection (without GUI) and make some system call, and this process will start using OSx GUI
I don't really understand your question, but I suspect you maybe have a look at the "expect" tool, which allows you to start some connection and then let the user continue after you have established the connection. Try:
man expect
in a terminal window.

How to get tabs in unix session on putty

I have used an script in past that enabled me to connect me to multiple unix machines, much like using a tab. Its just that I forgot the name of the script. Anyone know about it?
I suspect you're referring to GNU screen, which is a terminal multiplexer that allows you to have multiple virtual terminal windows in a single normal terminal window (ala PuTTY). I'd suggest tmux as a better alternative, but they're essentially the same. There are other solutions that will allow you to do tabs in the terminal client, but that depends on your OS (I'm assuming you're on Windows), and you'd have to initiate each connection individually. screen/tmux is the way to go most of the time.

Hook up into another Terminal process?

I've got two terminal instances/processes opened with different PID.
Is it possible to from one of them, hook up into the other so when I type something and it outputs something, then the other terminal will see the output too (maybe the input too if possible?).
Just like cloning the terminals.
I want this because then I can hook up some SSH processes and everyone connected to the machine could see what the other one is doing and could also collaborate.
I don't want to use any GUI or other workarounds for this.
Want it to be in process level.
I'm using Ruby and Ubuntu.
Install GNU Screen, run screen in the first terminal, then screen -x in the second.
(This works for both input and output).
Go hack the kernel.
But if you need a practical workarou^Wsolution, I'd advise using screen.

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.

Resources