Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, I did some work on the server of my university. I want to copy it on my computer. I tried scp witouth succes. My problem is I log to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2013
    Posts
    4

    SSH with an IP and an address


    Hi,

    I did some work on the server of my university. I want to copy it on my computer. I tried scp witouth succes. My problem is I log to ssh with : ssh username[a]adress.com and after I have to choose the server name 192.168.*.*.

    How can you use scp like this to make it work ?
    scp username[a]adress.com 192.168.*.* /home/username/file.txt
    > /home/user/file.txt

    Thank you

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    hi,

    i'm not sure about your syntax. here is an example, to get you going:

    Code:
    scp ~/file.txt username@192.168.1.2:
    the file "~/file.txt" is in your home dir on the local machine.

    the "username" is the account on the remote host that you use to log in.

    the "192.168.1.2" is the remote machine's ip address. you could also use a resolvable hostname (but not both!)

    everything after the ip address (or hostname) and colon is the remote path. i have left it blank, which means to copy it the remote home dir. you could also supply "~", or absolutely refer to a directory, like "/home/username" or "/tmp", or you could also specify the home dir using ".", though that is redundant, and you may as well leave it blank.
    Last edited by atreyu; 10-03-2013 at 01:17 AM. Reason: i meant "scp" in the command, not "ssh"...sheesh

  3. #3
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,356
    Your usecase is a bit hard to comprehend.

    From what I understood:
    - You are on your local computer
    - Then you need to login to a host at "adress.com" first
    - From there you jump to a another server with the IP 192.168.*.*
    So the problem is: You want to copy files from 192.168.*.* to you local computer via "adress.com"

    If so, then you could the ssh proxy command:
    On your local machine:
    - Create a ssh keypair, if you dont have one already (look for and in ls -la ~/.ssh/)
    Code:
    ssh-keygen
    . Use a strong passphrase to protect your private key.
    Code:
    mkdir ~/.ssh/connections
    - create a ssh config file with a texteditor of your choice: ~/.ssh/config with the following content:
    Code:
    Host *
      ForwardAgent yes
      ControlMaster auto
      ControlPath ~/.ssh/connections/%r_%h_%p
    
    Host uni_server
      HostName 192.168.*.*  ## (replace with real IP or better fqdn)
      ProxyCommand ssh adress.com nc %h %p
    - copy your public key to address.com and the uni_server
    Code:
    ssh-copy-id username@address.com
    ssh-copy-id username@uni_server
    Now you should be able to connect to "uni_server" from your local computer as if uni_server was directly reachable.
    ie this should work:
    Code:
    scp username@uni_server:~/file.txt .
    So what happens?
    ssh/scp do not use a given hostname or IP directly, but first consult the ssh configfile.
    We defined a "virtual" hostname uni_server, which is reachable via a proxy.
    So whenever uni_server shall be reached, ssh/scp will first connect to address.com and call nc (netcat) there to connect to the IP 192.168.*.*
    On some distributions nc is called netcat. If you encounter a file not found, then try netcat instead of nc

    The local directory ~./.ssh/connections is not strictly neccesary.
    It is used for multiplexing connections.
    You need to establisch at least one connection to address.com, which includes tcp handshake, dns resolving etc.
    But follow up connections to the same destination can just use the existing one.
    These lines enable ssh to do so
    Code:
    Host *
      ControlMaster auto
      ControlPath ~/.ssh/connections/%r_%h_%p
    You must always face the curtain with a bow.

  4. #4
    Just Joined!
    Join Date
    Sep 2013
    Posts
    4
    Thank you Irithori, I will test it.

  5. #5
    Just Joined!
    Join Date
    Sep 2013
    Posts
    4
    Where do I copy the keys ?

    ssh-copy-id username@address.com
    ssh-copy-id username@uni_server

    thank you

  6. #6
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,356
    ssh-copy-id searches the local default path ~/.ssh and copies your public key to ~/.ssh/authorized_keys of username on the remote hosts.
    You must always face the curtain with a bow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •