Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I have 2 computers on linux (ubuntu like), both are on separated local networks (192.168.xxx.xxx).
I would like to connect through ssh to Linux2 from Linux1 but it doesn't have any public IP.
I have also a public server (srv.domain.com)
I suppose that both PC could connect to server and it would be able to forward commands ??
But I can't figure out how to do that. Is someone already did something similar and can explain it to me.
I have root access on all machines
Thanks a lot for your help !!!
The easiest way would be to make the firewall/router allow ssh connections between the hosts. But there is another way:
If your server can reach both clients, you can ssh onto the server and redirect a port to the ssh on the other machine:
ssh -L 1234:CLIENT2:22 -l USERNAME SERVERNAME
after logging into the the machine open another terminal window and enter:
ssh -l USERNAME -p 1234 localhost
USERNAME should be replaced with the username on the server/second
client.
CLIENT2 should be replaced by the ip or hostname of the
second client.
SERVERNAME should be replaces by the name of your
server.
You can also ssh onto the server and open another ssh session from there. But that would be to easy ;)
If your server cannot reach the clients you have to build the tunnel the other way round:
ssh -R 1234:22 -l USERNAME SERVERNAME
after logging into the the machine open a terminal window on the other machine and enter:
ssh -l USERNAME -p 1234 SERVERNAME
USERNAME should be replaced with the username on the server/second
client.
SERVERNAME should be replaces by the name of your
server.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I'm trying to set up a virtual machine with CentOS 7 to use it as an Oracle Database Server (I'm new to Linux). I have encountered a problem about the host configuration that as I was reading has to be configured previously.
You see, this is where I collide with my knowledge that I have in windows. I thought it was enough to change the device name like this:
[root#localhost.localdomain ~] # hostname SERVER01
[root#localhost.localdomain ~] # hostname
SERVER01
[root # SERVER01 ~] #
And I do not understand why from windows I can not ping the Linux machine only using its hostname (SERVER01)
The ping request could not find host SERVER01. Check the name and
try again.
I understand that the previous configuration of the host in CentOS 7 that I am asked to install the database server has to do with the fact that I can not ping it using SERVER01. Although I have to clarify that using the IP if I can.
What do I do to make that change in Linux and can ping only using the hostname as it happens in windows?
When you change the hostname in linux you are essentially just telling the OS "this is your name".
In order to reflect that on the network mapping as well, you need to edit the hosts file:
nano /etc/hosts
or if you are a vi fan:
vi /etc/hosts
Note that you will need root access to do this.
In that file you can just extend the localhost mapping to also include your custom hostname SERVER01
127.0.0.1 localhost.localdomain localhost SERVER01
Once you do this, from the same CentOS terminal you can type ping SERVER01 and it should give you a proper ping results.
If you want to be able to ping and access the services on that virtual machine from your Windows OS, then you will need to do the same mapping through the hosts file on your Windows, but this time you will have to use the IP provided to the vm, instead of 127.0.0.1.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I'm trying to tunnel to a remote VM.
I previously used the below command:
ssh -N -p 22 username#1.2.3.4 -o StrictHostKeyChecking=no -L 127.0.0.1:8080:5.6.7.8:443
Something went wrong with the server at the weekend and the SA had to restore the image.
Now when I try to do this I get prompted with the following:
Permission denied, please try again.
username#1.2.3.4's password:
I don't know what this password should be and the SA isn't available.
I am able to ssh directly onto 1.2.3.4 using my public key and when on it I can ssh onto 5.6.7.8 with this command:
ssh -A blueboxadmin#5.6.7.8
Is there any way I can use this to tunnel right through. Failing that, is there anything I can setup on 1.2.3.4 that will allow me to tunnel through?
Looks like the ssh key value pair is missing from the remote server.
You will have to copy the entry of you server ssh key (from $HOME/.ssh/id_rsa.pub file) into the remote server's $HOME/.ssh/authorized_keys file. Make sure the key is pasted in a single line. After doing this, you should be able to connect.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I am actually scratching my head about this one.
I found this excellent guide for for port-forwarding via multiple ssh-hops.
Folowing this guide I tried this:
This works:
$ ssh -t hop -L 9080:localhost:9080 \
> ssh -A -t user#192.168.1.100 -L 9080:localhost:9080
with .ssh/config
Host hop
User extUser
IdentityFile ~/.ssh/id_rsa.company.pub
Hostname company.com
ForwardAgent yes
Port 11000
This actually opens a port on my machine via hop to the 100 target machine's service at port 9080.
The hop server has access to 192.168.1.100:9080 (i.e. wget 192.168.1.100:9080 succeeds)
So according to the guide, this should work as well:
ssh -L 9080:192.168.1.100:9080 hop
But it does not. It opens the connection to the hop ssh point (-f -N) would prevent this) but the tunnel is not forwarded to the destination. What am I missing?
Of course finally it should be all in the .ssh/config:
Host tunneled-9080
User extUser
IdentityFile ~/.ssh/id_rsa.company.pub
Hostname company.com
ForwardAgent yes
Port 11000
LocalForward 9080 192.168.1.100:9080
so a simple
ssh -f -N tunneled-9080
is all I need.
What am I missing?
Just for the record, if someone comes to this question.
Everything above is correct and works. What tricked me, was my way too clever browser which converted sometime through the trying out localhost:9080 into www.localhost.com:9080 which of course failed horribly. dough
Stupid clever firefox
The first command (combined with the ssh config) is logging into hop as user extUser and from there logging into the 100 machine as user user.
While the second command tries to log into both machines as user extUser. This is probably why it fails - because user extUser does not have access setup on the 100 machine.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I'm a complete begginer in Linux, especially in Linux for servers. I just installer Ubuntu in a server and now I'm trying to configure SSH for remote access.
I installed openssh-server and then did ufw allow 22.
Now when I do ssh username#XXX.XXX.X.XXX in another computer it says that the remote host identification was changed.
I did some research and found this tutorial, but I don't know if it is what I need.
I just want to configure the SSH access to the server.
Can anyone help me?
During SSH request the server presents its id to clien which the client stores along with the host name/IP of the server as known hosts.
When the ID(key) of the server changes(may be due to intallation of ssh server, ip address change, etc), the SSH request fails as the server ID stored in known_hosts is different from the one presented now. This is what has happened.
If you have not made any changes to the server and this happens beware it might indicate a man-in-middle attack where the attacker is trying to snoop you connection to server.
To fix this you need to remove a entry in known_hosts file.
ssh-keygen -R <hostname/IP>
If you are unsure about your client hostname you can just delete the known_hosts file using
rm ~/.ssh/known_hosts
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I need to ssh to a remote host 2 when I am "sshed" in other remote machine (remote host 1). For example, from remote host1 I need to execute:
ssh -i MY_PRIVATE_KEY_FILE_NAME myname#remotehost2
However, my private key file is on my local machine. How can I specify it?
You can use ssh agent to forward your local key.
Start your agent (should be already installed) with
ssh-agent
then add your local key
ssh-add /path/to/your/keyfile.key
then login to serverA
ssh -A userA#serverA
Now you should be able to login at serverB with you local key.
Options:
scp the key to remote host 1
Copy the key manually, i.e. copy locally, open an editor on remote host 1, paste, save.
Connect to remote host 2 from a different local terminal (or drop the connection in the one you're on)
Set up ssh forwarding. I believe it would be something like ssh -R 12345:remotehost2:22 user#remotehost1, then from local ssh -p 12345 user#remotehost1. Note that user in the second command is the username for remotehost2, despite apparently connecting to 1.