I am currently working on a windows 10 laptop. I have installed the ubuntu subsystem (instead of PUTTY) in it to access the remote server. When I launch the ubuntu subsystem from my windows start menu, it opens with a command prompt user@PC0BCD-PC
The remote server is a Linux server as well.
In addition, I am connected to a VPN. If I don't connect to the VPN, I will not be able to login to the remote server.
So, what I would like to do is transfer the file from my local windows ubuntu subsystem to the remote server
So, i tried the below command and got an error as shown below
scp /mnt/c/Users/test/Downloads/DC_cond.csv .Z:/home/test/cond_occ.csv
ssh: connect to host 172.XX.YYY.Z port 22: Resource temporarily unavailable
lost connection/mnt/c/Users/.... indicates the path in my local system whereas .Z indicates my remote server address.
when I type telnet 172.XX.YYY.Z 22 in my WSL, it just says Trying 172.XX.YYY.Z whereas when I SSH into remote server and type telnet 172.XX.YYY.Z 22, it produces output for telnet command
Am unable to transfer files from remote server to local system as well.
Can help me with this?
12 Answers
From the comments, we discovered that the "core issue" was that you were able to access the server when ssh, and from there you could scp. But when attempting to scp directly into the server from your WSL session on the VPN, it was not accessible.
For future readers, there could be several (other) reasons for scp not working when ssh does:
There could be a server issue. Some servers running certain versions of
libssh2are reported to have an issue withscp, although that has been fixed for a while, so it would be rare to see this.The shell startup files on the server could be emitting some text. This would work with an interactive
sshsession, but would cause issues withscp. However, the error messages that you are seeing aren't quite aligned with that.
It turns out, it seems, that you were using the hostname with ssh, but you were attempting to use the IP address with scp. The hostname worked, because you have the following in your ~/.ssh/config:
Host server_1
Hostname 172.xx.yyy.z
User test
ProxyCommand ssh -q -a pitunnel -W %h:%p
TCPKeepAlive yesThis allowed the ssh server_1 to use the ProxyCommand to connect through a server on the VPN named pitunnel to server_1.
While you already discovered that you can simply use the server_1 hostname with scp to get it to work (since it also reads the same ~/.ssh/config), you should be able to also modify the config to allow access hostname and IP. Just change the first line to be:
Host server_1 172.xx.yyy.zThis tells ssh and scp to use the settings below for both hostname and IP.
One additional note. You are smart to obscure the IP address, but it likely isn't necessary in this case. If xx is between 16 and 31, then the IP address is on what is known as a "Private Internet" network. It's just like the 192.168.1.1 type addresses that you see on your home router. Everyone can use the same IP ranges, because they aren't routable over the public Internet.
That's why you have to connect to the VPN and use a proxy to access it. It isn't on the public Internet to begin with.
0openssh-server might not be installed on the server or port 22 might be firewalled by the server or the VPN router.
To check the latter you could change the port to use in the openssh-server config on the server just add/replace the Port configuration to /etc/ssh/sshd_config
Port 80or any port you are sure is not blocked by the firewall.
Than use ssh -p 80 <some_user>@<some_ip>
You could use any other port as well (just swap out 80 for another reasonable port), but port 80 is most likely not restricted.
If you already have a service binding to port 80 you will run into trouble changing the configuration. To list all used port on the server you can use ss or netstat as described by Pierre ALBARÈDE in his comment.