LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-21-2018, 12:19 PM   #31
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721

Quote:
Originally Posted by drudox View Post
ok .. but my mashine have no a static IP addr ! soi which
Code:
HostName
I have to give there ?
The machine you are connecting from does not need a static IP address itself. However, the machine you are connecting to does need some kind of permanent host name or IP number. If the target machine has a dynamically allocated IP address it will change and you can compensate by signing it up for a dynamic DNS service like No-IP.com

In the SSH client configuration file (that is to say on the machine you are connecting from) the configuration directive "Host" contains the shortcut names. The "HostName" configuration directive points to the fully qualified domain name (fqdn) or permanent IP address.
 
Old 10-21-2018, 12:35 PM   #32
drudox
Member
 
Registered: Feb 2016
Posts: 141

Original Poster
Rep: Reputation: Disabled
no no the machine who I try to connect from have a static IP .. and of course DNS
 
Old 10-21-2018, 12:43 PM   #33
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Ok. But the client machine only needs an outgoing connection, it does not matter whether it is static or dynamic. However, the machine you are connecting to is another matter.

What is the situation regarding permanent IP address or fully qualified domain name for the machine you are connecting to? That is what needs to go into the HostName directive in ~/.ssh/config on the SSH client machine.
 
Old 10-21-2018, 01:15 PM   #34
drudox
Member
 
Registered: Feb 2016
Posts: 141

Original Poster
Rep: Reputation: Disabled
the machine who I try to connecting have a stati ip .

so basically this file on my local machine is correct ?

Code:
Host my March
        User marco
        HostName March
        IdentityFile ~/.ssh/office.ed25519.key
        IdentitiesOnly yes
        ServerAliveInterval 30
        ServerAliveCountMax 4
 
Old 10-21-2018, 01:20 PM   #35
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
The part "HostName March" has to point to the full host name of the destination machine. So replace "March" with the full address.
 
Old 10-21-2018, 01:37 PM   #36
drudox
Member
 
Registered: Feb 2016
Posts: 141

Original Poster
Rep: Reputation: Disabled
and .. so why in my office machine I had just insert :

Code:
Host lab 130.159.43.40
        User marco
        HostName 130.159.43.40
        IdentityFile ~/.ssh/office.ed25519.key
        IdentitiesOnly yes
        ServerAliveInterval 30
        ServerAliveCountMax 4
------------------------------------------------------------
Now why I have to put the hostname of the macghine which I'm pointing ?

basically the same file ?
 
Old 10-21-2018, 01:43 PM   #37
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Now you can type either "ssh lab" or "ssh xxx.yyy.zz.aa" and then all the configuration settings associated with that shortcut will be added automatically.
 
Old 10-21-2018, 01:50 PM   #38
drudox
Member
 
Registered: Feb 2016
Posts: 141

Original Poster
Rep: Reputation: Disabled
thank you very much it works!! but in order to doing the same thing (office->lab->server) I have to ass another block in the .ssh/config ?
 
Old 10-21-2018, 02:21 PM   #39
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Quote:
Originally Posted by drudox View Post
thank you very much it works!!
Good work!

Quote:
Originally Posted by drudox View Post
but in order to doing the same thing (office->lab->server) I have to ass another block in the .ssh/config ?
Yes. Check it manually first and then transfer the settings to ~/.ssh/config after the settings you've just added. Substitute the real server key name for the ->server key below:

Code:
ssh -i server.ed25519.key -o 'ProxyCommand ssh -i ~/.ssh/office.ed25519.key -W %h:%p marco@lab' marco@node_1
Then if that works:

Code:
Host lab 130.159.43.40
        User marco
        HostName 130.159.43.40
        IdentityFile ~/.ssh/office.ed25519.key
        IdentitiesOnly yes
        ServerAliveInterval 30
        ServerAliveCountMax 4

Host server
        User marco
        HostName xx.yy.zz.aa
        IdentityFile ~/.ssh/server.ed25519.key
        IdentitiesOnly yes
        ServerAliveInterval 30
        ServerAliveCountMax 4
        ProxyCommand ssh -i ~/.ssh/office.ed25519.key -W %h:%p marco@lab
Then "ssh server" ought to get you through.

You are setting the 'lab' machine as a jump host or bastion host, both names are common.
 
Old 10-21-2018, 03:23 PM   #40
drudox
Member
 
Registered: Feb 2016
Posts: 141

Original Poster
Rep: Reputation: Disabled
very strange .. if I give :
Code:
ssh -i server.ed25519.key -o 'ProxyCommand ssh -i ~/.ssh/office.ed25519.key -W %h:%p marco@lab' marco@node_1
inside
Code:
~/.ssh
directory .. it works fine

other wise it ask me password and so on
what I'm wrong ?
 
Old 10-21-2018, 03:38 PM   #41
drudox
Member
 
Registered: Feb 2016
Posts: 141

Original Poster
Rep: Reputation: Disabled
ok
now this part is done (thank you so much Turbocapitalist )... back to the topic .. how can i rub scrip in ssh without these stop when I log out ?
I was thinking to use nohup but i'm nor sure if it doesn work in thi way
 
Old 10-21-2018, 04:28 PM   #42
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by drudox View Post
very strange .. if I give :
Code:
ssh -i server.ed25519.key -o 'ProxyCommand ssh -i ~/.ssh/office.ed25519.key -W %h:%p marco@lab' marco@node_1
inside
Code:
~/.ssh
directory .. it works fine

other wise it ask me password and so on
what I'm wrong ?
Put the full path to the server key file.
When you run from another directory, ssh doesn't know where the server.ed25519.key file is.
 
Old 10-21-2018, 10:40 PM   #43
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Ryan's Tutorials has a good tutorial on paths and navigation of the file system. It will provide the necessary background information to be able to point to the keys from anywhere.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
In shell script how can i change the user using sudo -s and it asking password. So in script how to password sopanlavhale Linux - Newbie 5 06-14-2018 12:03 PM
How can I run a script using sudo with the password ? wlaw Linux - Software 8 08-15-2013 02:51 PM
[SOLVED] sudo ask for password if run using script limgrace Linux - General 10 10-24-2012 07:26 AM
How do I use sudo in a script without asking for password? Usalabs Linux - General 1 08-28-2008 01:59 PM
Shell script sudo without password prompt under Darwin? lhouk Other *NIX 3 02-08-2008 11:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration