How to auto connect jumper or proxy and server with one command ssh [closed] - linux

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 4 years ago.
Improve this question
I remember one of my friend is using ssh file configuration to make it be done, but I can't find the command that should be written in that file to achieve this result.
So what he did is just type the command
ssh [alias of the server]
and the shell automatically go to jumper (proxy) submit the password in there,
then go to the server and again submit the password there, so he doesn't need to re-enter password during ssh into the server.
Another question, is this able to be done for Windows server?

You can use something like this:
Host jump
User [username]
HostName [ip address]
Host [server ip address] [server alias]
HostName [server ip address]
User [username]
Port [port]
ProxyCommand ssh -q -W %h:%p jump 2>/dev/null
Host Jump is a proxy server.
The command that will help you take a leap on the proxy server then continue to the server is ProxyCommand.
%h: is using your username
%p: is using your password from id_rsa.pub.
Reference: https://www.ssh.com/ssh/config/

I've never tried this except with public key authentication, but assuming:
You want to ssh from origin-box to target-box
target-box has a network name of target.box.domain
origin-box is not authorized on target-box
proxy-box is authorized on target-box
origin-box is authorized on proxy-box
You ssh/config on origin-box would be something like:
Host target-box
ProxyCommand ssh -q proxy-box -W target.box.domain

Related

How to copy files over ssh [closed]

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
How do I copy a file using ssh from my test server to my production server, how do I do this for a single file and how do I do this for multiple files?
From Window to Linux
Download https://cygwin.com/ this will give you a proper terminal which will then allow you to run the linux commands as listed below in the From Linux to Linux section.
From Linux to Linux
The essential command is this
The command
scp [ssh login to remote server]:[filepath] [local filepath]
To copy a single file example
scp user#your.server.example.com:/path/to/foo/[filename] /home/user/Desktop/[filename]
To copy a directory example
scp -r user#your.server.example.com:/path/to/foo /home/user/Desktop/
To use full power of scp you need to go through next steps:
Setup public key authentication
Create ssh aliases
Then, for example if you'll have this ~/.ssh/config:
Host test
User testuser
HostName test-site.com
Port 22022
Host prod
User produser
HostName production-site.com
Port 22022
you'll save yourself from password entry and simplify scp syntax like this:
scp -r prod:/path/foo /home/user/Desktop # copy to local
scp -r prod:/path/foo test:/tmp # copy from remote prod to remote test
More over, you will be able to use remote path-completion:
scp test:/var/log/ # press tab twice
Display all 151 possibilities? (y or n)

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

Telnet File Transfer between two linux machines [closed]

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 want to send a file from one Linux machine with IP suppose "192.168.2.25" to other Linux machine that's a server "192.168.2.110"
how can i do that by using Telnet command??
A simple option is to use netcat (nc). This is particularly useful on stripped down Linux systems where services like ssh and ftp are turned off.
On destination machine run the following command: nc -l -p 1234 > out.file
On source machine run the following command: nc -w 3 <dest-ip-adr> 1234 < out.file
For more details look, for example, here.
There are also netcat implementations for Windows, e.g. ncat.
While it may not be possible with only telnet, it is possible with telnet and netcat. Some of the examples above just referenced using netcat, but there have been times when I was on an old machine that was still in production that had telnet but not netcat. In this case, you can set netcat to listen on a newer, remote machine and telnet the file to it.
On the newer remote machine:
netcat -l <PORT> > OUTPUT.FILE
On the older telnet only machine:
cat FILE | telnet REMOTE-HOST PORT
Note that this works with text files. If you have a binary file of some sort you would need to do further manipulation on both ends.
Telnet just gives you a remote terminal session. The best you could do is telnet, open a new file in an editor and copy/paste the text from the local machine.
To copy files use something like rsync, scp, rcp or ftp.

How to use linux command line ftp with a # sign in my username? [closed]

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 8 years ago.
Improve this question
How can I run this on linux command line when my username has an # sign in the middle?
ftp -u user:password#host/destination_folder/ sourcefile.txt
My username is info#domain.com and it thinks my host is domain.com.
NOTE: This is an unattended upload, so I can't just type in the username and password.
Try this: use "%40" in place of the "#"
As an alternative, if you don't want to create config files, do the unattended upload with curl instead of ftp:
curl -u user:password -T file ftp://server/dir/file
Try to define the account in a ~/.netrc file like this:
machine host login info#domain.com password mypassword
Check man netrc for details.
I simply type ftp hostdomain.com and the very next prompt asked me to enter a name, if it wasn't the same as my current user.
I guess it depends on how your FTP is configured. That is, whether it assumes the same username (if not provided) or asks. the good news is that even without a solution, next time you face this it might Just Work™ for you :D
A more complete answer would be it is not possible with ftp(at least the ftp program installed on centos 6).
Since you wanted an un-attended process, "pts"'s answer will work fine.
Do the unattended upload with curl instead of ftp:
curl -u user:password -T file ftp://server/dir/file
%40 doesn't appear to work.
[~]# ftp domain.com
ftp: connect: Connection refused
ftp> quit
[~]# ftp some_user%40domain.com#domain.com
ftp: some_user%40domain.com#domain.com: Name or service not known
ftp> quit
All I've got is to open the ftp program and use the domain and enter the user when asked. Usually, a password is required anyway, so the interactive nature probably isn't problematic.
[~]# ftp domain.com
Connected to domain.com (173.254.13.235).
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 2 of 1000 allowed.
220-Local time is now 02:47. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (domain.com:user): some_user#domain.com
331 User some_user#domain.com OK. Password required
Password:
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
curl -f -s --disable-epsv -u someone#somewhere.com:gr8p455w0rd -T /some/dir/filename ftp://somewher.com/ByramHealthcareCenters/byram06-2011.csv
I've never seen the -u parameter. But if you want to use an "#", how about stating it as "\#"?
That way it should be interpreted as you intend. You know something like
ftp -u user\#domain.tld#ftp.host.tld

Resources