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.
Related
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 3 years ago.
Improve this question
I often ssh tunnel into Rstudio on a server I have set up. I'm trying to devise a single command that I can use to close the ssh port. I know that I can find the PID for localhost:1234 with:
sudo lsof -i :1234
And I also know that I can kill the process with:
sudo kill $(sudo lsof -t -i:1234)
The issue is that if I have Chrome open to run Rstudio server, the 2nd command will kill the open Chrome browswer as well. Is there a way to modify the 2nd command so that I close the open ssh port, but not the Chrome browser? There are two PID numbers, so I could theoretically grep for 'ssh' but I'm not sure how.
EDIT FOR CLARITY:
For example, I get the following output from the first command. I want to modify the 2nd command so that I can kill PID 15834, but not 30117. Apologies, I hope that makes more sense.
try this
sudo kill $(sudo lsof -t -i:1234 -c ssh)
-c => selects the listing of files for processes executing the command that begins with the characters of c.
Just firewall the port:
sudo iptables -I INPUT -p tcp --dport 1234 -j DROP
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 6 years ago.
Improve this question
I'm trying to copy a folder from one system to another using scp (secure copy) however I cannot work out how to specify the port.
I understand that to scp, I can...
scp /file/location/folderName user#192.***.*.***:/destination/location/
however I have changed the destination system's SSH port so I get get this error...
ssh: connect to host ..*.*** port 22: Connection refused lost
connection
Is there some sort of -p command I can use to specify port number?
I also tried adding the port like this...
scp /file/location/folderName user#192.***.*.***:>>portNumHere<</destination/location/
Updated with solution...
I was struggling not only with using the wrong -P but also where to place. I know understand and this works for me...
scp -r -P >>portNumHere<< /file/location/folderName user#192.***.*.***:/destination/location/
Use a capital -P port. The lower case -p option conflicts with the -p "preserve" option from cp.
Per the man page:
scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[user#]host1:]file1 ... [[user#]host2:]file2
...
-P port
Specifies the port to connect to on the remote host. Note that
this option is written with a capital āPā, because -p is
already reserved for preserving the times and modes of the
file.
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)
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 do you check if a port is open when you cannot use telnet or install Cacti? I want to see if a port is open between two Linux servers. Telnet isn't installed. I tried this command:
cat < /dev/tcp/x.x.x.x/6061
where x.x.x.x was the remote IP address of the Linux server and port 6061 is the port that I want to test. But based on tests of known working and not working ports, this command wasn't conclusive to me. There may be an environmental explanation for that.
Install nmap and than:
nmap x.x.x.x
Better use (if installed) : netcat :
nc -zw3 <host> <port>
If you want to use the bash feature net redirection :
cat < /dev/tcp/x.x.x.x/6061
do it the right way :
{ exec 3<> /dev/tcp/127.0.0.1/6061; } &>/dev/null &&
echo "Connection to socket OK" ||
echo >&2 "Can't connect"
If it doesn't work, you need to compile bash with --enable-net-redirections
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.