SSH Port forwarding in a ~/.ssh/config file? [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
So I typically run this command a lot:
ssh -L 5901:myUser#computer.myHost.edu:5901
I use it to do VNC over SSH.
How do I convert that command into something that will work in a ~/.ssh/config file?
ex:
host yam
HostName yam.myHost.edu
User myUserName
all I want to do is type:
ssh yam
And have it open a SSH shell with a local listen port, and a remote port forwarded to it.
Suggestions?

You can use the LocalForward directive in your host yam section of ~/.ssh/config:
LocalForward 5901 computer.myHost.edu:5901

Related

How to find out which process is using localhost:80? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm using linux mint xfce edition, my localhost:80 was used by some program but I don't which one, when I open firefox and visit localhost:80, it says
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
I've tried to use lsof -i #localhost:80, but it returns nothing.
netstat -anpt | grep :80 as root user should list process using port 80.
With your web browser closed it can help you identify the process.
Try this:
# fuser -n tcp 80
From the manpage:
-n SPACE, --namespace SPACE
Select a different name space. The name spaces file (file names,
the default), udp (local UDP ports), and tcp (local TCP ports)
are supported. For ports, either the port number or the symbolic name can
be specified. If there is no ambiguity, the shortcut
notation name/space (e.g. 80/tcp) can be used.

how to tunnel to another computer using a middle computer? SSH [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am in my local computer, and i just want to test reverse ssh so that i access computer 2 and access computer 3 through computer 2 and make computer 3 respond to me in lets say i want to access postgresql on computer 3.
how to do that with ssh and using ports? 5432 is the port of sql
my approach is this:
ssh -L 3000:localhost:5432 <ipaddressof the 2nd computer>
so im inside 2nd computer now.
in the terminal again i type:
ssh -L 3000:localhost:5432 <ipaddress of the 3rd computer>
and im inside the 3rd computer now. And i dont know what to do anymore, how to access its sql?
i tried this code which doesn't work:
psql -U myusername -p 3000
Try the following:
ssh -L localhost:3000:<ip address 3rd computer>:5432 <ip address 2nd computer>
And then:
psql -U myusername -h localhost -p 3000
This works if:
The 2nd computer has access to the 3rd computer
The sshd config on the 2nd computer allows TCP forwarding (default is yes)

How do I establish a bidirectional SSH Tunnel [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Is it possible to do the following via an SSH tunnel...
Host-1 establishes an SSH connection to a Remote Server
I wish to log into the Remote Server and execute commands over SSH back on Host-1
Host-1 is a device that I will not have access to directly. Host-1 is set up to automatically establish an SSH connection to a remote server via cron. At any point while Host-1 has established an SSH connection to the Remote Server, I wish to log into the Remote Server in order to perform maintenance on Host-1 via SSH.
I am looking for an example of how this would work if its possible.
Like this:
host1$ ssh -N -R 8822:localhost:22 remote.host.com
The optional -N says "don't execute a command" (helpful to prevent accidents caused by leaving remote shells laying around.)
Now from remote, you can SSH to host1 like this: (The remote port 8822 forwards to host1, but only on the loopback interface.)
remote$ ssh -p 8822 localhost
For extra credit, you can export the forwarding to the whole world, allowing anyone get to host1 by hitting remote's port 8822. (Note the extra initial colon)
host1$ ssh -N -R :8822:localhost:22 remote.host.com

how to make ssh fail if any parameter is wrong [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm using the command ssh -i /home/ssh_keys/10_1_1_127 root#10.1.1.127 date for checking the date on some other machine,
If some parameter is wrong, like the user, the ip or the identity file doesn't exists,
ssh asks for password
for example, if I write ssh -i /home/ssh_keys/10_1_1_1277 root#10.1.1.127 date
whilst /home/ssh_keys/10_1_1_1277 doesn't exists, I get:
root#10.1.1.127's password:
I wanted to know if it is possible, and if so, then how to make ssh fail if some parameter isn't right, so ssh won't ask me for a password if I enter wrong parameters...
Thanks
All these changes should be done via root or a sudo enabled user.
In /etc/ssh/sshd_config set the following entries to no:
ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no
If you need help finding those specific lines, use grep:
grep -n "PasswordAuthentication" /etc/ssh/sshd_config
^^or whatever^^
This outputs the line number
Then restart ssh
/etc/init.d/ssh restart
or
service ssh restart
depending on your flavor of Linux.

Stop ssh service at specific port [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've started multiple ssh services at a range of port for a particular testing using
/usr/sbin/sshd -p portnumber
How do i stop service at a specific port where i've started ?
I've seen this command (But dats general, i have to stop at a specific port)
/etc/init.d/ssh stop
To stop all instances you can use:
killall sshd
If you want a specific one you need to use ps aux | grep sshd -p <port>. There you get the pid (process id) which you can simply kill by kill <pid>.

Resources