Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am sure this has been asked before, but I don't know how to phrase it to search correctly.
I ssh to a server and issue do some port forwarding. Its a long command line string that I either need to type or copy and paste from history.
Can't I create a file, that contains this information and the just issue "ssh mysever" and have it look in that file for the specific port to forward and other parameters?
I even have an old example but don't know where to put it or the file name
Distribution: Distribution: RHEL 5 with Pieces of this and that.
Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,697
Rep:
There are several ways to do this easily.
1. Create a script like this and name it say ssh_myserver. Put it in your /usr/bin so it can easliy be executed from the command line and can be found in the default users path.
Code:
#!/bin/bash
ssh -Y username@192.168.1.1 (Place your command here on this line).
Save and exit.
Then make it executable. chmod +x /usr/bin/ssh_myserver
2. To make the command an alias and place it in your home ~/.bash_profile
Examples: edit your .bash_profile and add a line like this.
alias ssh_myserver="place command here using full path"
alias ssh_myserver="ssh -Y username@192.168.1.1"
Once saved the command to reread the bash_profile eludes me off the top of my head. Logout and then log back in will reread the bash_profile.
edit: The command to reread the .bash_profile is the source command.
source .bash_profile
edit:
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660
Rep:
I would not recommend using ssh -Y as your default way of invoking ssh. Do that only when you're connecting to a server that you want to export X applications from and you fully trust the administrator of the machine not to annoy you (say, by opening a million xclocks on your desktop).
Distribution: Distribution: RHEL 5 with Pieces of this and that.
Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,697
Rep:
Never gave that I thought. So one from the remote machine can start opening xclocks on your local desktop. I am curious as to how this can be done. Not a person who fully uses the options in ssh but how does one send like xclocks over the connection to your display? I myself only connect ssh to my machines. No ssh accounts with others.
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660
Rep:
Quote:
Originally Posted by Brian1
Never gave that I thought. So one from the remote machine can start opening xclocks on your local desktop. I am curious as to how this can be done. Not a person who fully uses the options in ssh but how does one send like xclocks over the connection to your display? I myself only connect ssh to my machines. No ssh accounts with others.
Brian
Anyone with root (or sudo) access on the machine that you're ssh'ing to could open export any X application to the desktop that you were ssh'ing from. The way X forwarding works is it allows the remote machine to open X applications using your local X server (the application starts on the remote machine, but displays on your local machine). The authentication cookie to allow this is on the remote machine, so someone with root can use the cookie, or simply su to your account.
Distribution: Distribution: RHEL 5 with Pieces of this and that.
Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,697
Rep:
Beginning to see what can happen. Did some googleing and found bits and pieces. Mentioning the cookie helped in the search. But I haven't found a site that describes the technic. Would you know of a site that describes this.
Distribution: Distribution: RHEL 5 with Pieces of this and that.
Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,697
Rep:
Spent some time today and experimenting on two of my linux boxes. I was able to do exactly what you described and very simply. I see the security issue with usage of -Y and for that matter -X but not quite as serious but just as bad. One thing I need to figure out what command to show ssh connections from remote machines to the server on the server. And if all possible to see who it is logged in. I am sure that info is in the logs. So one would have to make sure those logs would be secure from users.
Thanks again for learning something new in linux.
Brian
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.