Avatar of andieje
andieje

asked on 

connect to server and scp

Hi

I am using Ubuntu 10.04. I normally use Places => connect to server to copy files from another linux machine via ssh.

I have been given a login to a remote machine which i connect via the command line using this command

ssh -X -L 3316:localhost:3316 username@ipaddress

Apparently this login automatically connects to me to another machine (on the same network i think) via ssh

I dont know how to access this machine using 'connect to server' or scp

I tried using 'connect to server' via ssh with a port of 3316 but it fails with message
'cannot display location sftp://username@ipaddress:3316/ timed out when logging in'

I don't know how the -X and -L options from the above can be specified with the ubuntu connect to server feature or even scp

thanks
Linux

Avatar of undefined
Last Comment
andieje
Avatar of farzanj
farzanj
Flag of Canada image

This is a command to create ssh-tunnel

Simply try to use

ssh  username@ipaddress

-L is for tunneling.
-X is for X server port forwarding.

If you want to do plain and simple ssh, you don't need these options.
Avatar of wesly_chen
wesly_chen
Flag of United States of America image

-L is for ssh tunneling.
It basically connect remote machine port 3316 to your local machine.
So you can access remote machine port 3316 by connecting to localhost:3316 once this tunnel is setup.

For direct ssh, you just do
ssh username@ipaddress
or
scp  <files to copy>  username@ipaddress:/path-to-target-dir
Avatar of Kerem ERSOY
Kerem ERSOY

Hi,

You do the SSH then the -X and -L are simply for forwarding ports to and from your system. So they are irrelevant in your case.

If you want to copy files you need to start SSH or SCP from your station..

With SSH retrieving files:

tar -czf - /path/to/localfiles | ssh hoastname tar -xzf - -C /local/path

With scp retreiving files:

scp username@hostname:/path/to/file /local/path

If you want to keep  a directory in sync with a remtote server you can use rsync over SSH:

rsync -ave ssh  hostname:/path/to/remote/folder /path/to/localfiles

Cheers,
K.


scp  /path/to/file

Cheers,
K.
Avatar of arnold
arnold
Flag of United States of America image

ssh username@localhost -p 3316 will send the connection through the tunnel established on the -L 3316:localhost:3316
The system to which this connects depends on the rule on the remote system that binds the remote system's local port 3316.
With the connect feature in ubuntu you would use localhost and port 3316 to get to where you want to be.
Avatar of andieje
andieje

ASKER

thanks for your replies but i must be doing something wrong

in the command line i opened the ssh tunnel like so

ssh -X -L 3316:localhost:3316 username@ipaddress

I then went to Ubunut connect feature and selected ssh and entered

server: localhost
port: 3316
username

but got error "cannot display location sftp://username@localhost:3316 ssh program exited unexpectedly"
Avatar of arnold
arnold
Flag of United States of America image

What does the 3316 port on the remote server do?

If you want to reach serverc that is on the same network as serverb from servera, the connection from servera to serverb has to be:
ssh -X -L 3316:serverc:22 username@serverb

I think the tunnel you were setting up was from localhost on servera to loclahost of serverb.

-L [localhost]:localport:[remotehost]:remoteport

If [localhost] is omited, this means that the port is listened to on all interfaces of the local system, (0.0.0.0) is implied in the absence of a [localhost] which can be localhost (127.0.0.1) or name_of_server (IP).
Avatar of andieje
andieje

ASKER

i should point out that i tried the obvious first:

ssh username@server

and got permission denied when entering password

but this works fine

ssh -X -L 3316:localhost:3316 username@ipaddress

I also tried copying a file via scp

scp username@server:/remotepath /localpath

It asks for my password and then hangs - no file is transferred and I tried with a very small file
Avatar of andieje
andieje

ASKER

@arnold - i can't get hold of the person who set this up but I do know that when i log in to the remote server the login automatically ssh's to another machine, presumably on the same network
ASKER CERTIFIED SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of andieje
andieje

ASKER

thanks
Linux
Linux

Linux is a UNIX-like open source operating system with hundreds of distinct distributions, including: Fedora, openSUSE, Ubuntu, Debian, Slackware, Gentoo, CentOS, and Arch Linux. Linux is generally associated with web and database servers, but has become popular in many niche industries and applications.

71K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo