Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for -F option #22

Open
labs-stellios opened this issue Jun 16, 2020 · 10 comments
Open

Request for -F option #22

labs-stellios opened this issue Jun 16, 2020 · 10 comments

Comments

@labs-stellios
Copy link

This is a request to support a -F configfile option. As a user, I'd like to preserve my normal SSH flow with a bastion whose details are captured in an SSH config file.

@spook
Copy link
Owner

spook commented Sep 8, 2020

Howdy @labs-stellios - What would be in this config file? The option switch values? I don't understand your request, sorry.

@demotomohiro
Copy link

Hello,
-F configfile option of ssh specifies an alternative per-user configuration file.
Format of this config file is explained in man ssh_config.

I think adding -F option to sshping and pass specified path to ssh_options_parse_config would be fine.

Adding -F option to sshping can solve #24 by adding ProxyJump option to the config file.
In my case, I need to set ProxyCommand option to connect my ssh server.

@labs-stellios
Copy link
Author

labs-stellios commented Oct 8, 2020

Ah sorry for the late reply, @spook . Here's an example host alias in my ~/.ssh/config if that helps. @demotomohiro has it spot on with the ProxyJump option:

Host some.place.cool
  HostName              127.0.0.1
  User                  yourstruly
  Port                  6255
  ProxyJump             bastion
  StrictHostKeyChecking no
  UserKnownHostsFile    /dev/null
  IdentityFile          /private/key/path.priv

@spook
Copy link
Owner

spook commented Oct 22, 2020

Ah, ok ... I get it. Sorry for being so dense. Yep we can do this.

@spook
Copy link
Owner

spook commented Oct 31, 2020

@labs-stellios I added the -F option, try it out, let me know if this is what you wanted.

@labs-stellios
Copy link
Author

labs-stellios commented Oct 31, 2020

Thank you! In my use case, I'm getting a socket error, where I can normally SSH in OK:

$ ./sshping -vvv -F $BASTION_CONFIG remotehostname
User: --not specified--
Host: remotehostname
Port: 22
Echo: cat > /dev/null
 Cfg: /path/to/my/bastion.config

+++ Attempting connection to remotehostname:22
[2020/10/30 22:03:40.680452, 2] ssh_connect:  libssh 0.9.3 (c) 2003-2019 Aris Adamantiadis, Andreas Schneider and libssh contributors. Distributed under the LGPL, please refer to COPYING file for information about your rights, using threading threads_pthread
[2020/10/30 22:03:40.680567, 2] ssh_socket_connect_proxycommand:  Executing proxycommand 'ssh -W [127.0.0.1]:6256 bastion'
[2020/10/30 22:03:40.680908, 2] ssh_socket_connect_proxycommand:  ProxyCommand connection pipe: [3,4]
[2020/10/30 22:03:40.680991, 1] socket_callback_connected:  Socket connection callback: 1 (0)
[2020/10/30 22:03:40.681027, 2] ssh_connect:  Socket connecting, now waiting for the callbacks to work
[2020/10/30 22:03:40.813318, 1] ssh_socket_exception_callback:  Socket exception callback: 2 (104)
[2020/10/30 22:03:40.813394, 1] ssh_socket_exception_callback:  Socket error: Connection reset by peer
*** Error connecting: Socket error: Connection reset by peer
*** Cannot establish ssh session

@spook
Copy link
Owner

spook commented Nov 24, 2020

Hi @labs-stellios,

I'm unable to reproduce the failure you got. It's working for me with a similar bastion config:

$ cat ~/.ssh/cow-jump.cfg
Host g4t8660g
  HostName              g4t8660g.(hidden).com
  User                  (hidden)
  IdentityFile          /home/spook/.ssh/id_rsa
  ProxyJump             spook@cow  
  StrictHostKeyChecking no
  UserKnownHostsFile    /dev/null

$ sshping -vv -F ~/.ssh/cow-jump.cfg g4t8660g
User: --not specified--
Host: g4t8660g
Port: 22
Echo: cat > /dev/null
 Cfg: /home/spook/.ssh/cow-jump.cfg

+++ Attempting connection to g4t8660g:22
[2020/11/24 11:48:54.344510, 2] ssh_connect:  libssh 0.9.5 (c) 2003-2019 Aris Adamantiadis, Andreas Schneider and libssh contributors. Distributed under the LGPL, please refer to COPYING file for information about your rights, using threading threads_pthread
[2020/11/24 11:48:54.344568, 2] ssh_socket_connect_proxycommand:  Executing proxycommand 'ssh -l spook -W [g4t8660g.(masked).com]:22 cow'
[2020/11/24 11:48:54.344739, 2] ssh_socket_connect_proxycommand:  ProxyCommand connection pipe: [3,4]
[2020/11/24 11:48:54.344790, 1] socket_callback_connected:  Socket connection callback: 1 (0)
[2020/11/24 11:48:54.344815, 2] ssh_connect:  Socket connecting, now waiting for the callbacks to work
[2020/11/24 11:48:55.635228, 2] ssh_client_connection_callback:  SSH server banner: SSH-2.0-OpenSSH_5.3
    . . .
+++ Connected to g4t8660g:22
+++ Authenticated by public key method
+++ Login shell established
ssh-Login-Time:         4417053582 ns
+++ Echo responder started
    . . .

A difference I noticed is you have libssh 0.9.3 and I have 0.9.4. But your verbose output shows that it has properly formed the older proxycommand string (ssh -W ...). What do you get with a simple ssh -v -J command for the "debug1: Setting implicit ProxyCommand from ProxyJump: ..." line and the following line, and how does it compare to libssh's output?

@labs-stellios
Copy link
Author

My usage seems off:

ssh -v -i /private/key/path.priv -J [email protected]:6255
usage: ssh [-@46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
           [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
           [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
           [-i identity_file] [-J [user@]host[:port]] [-L address]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-Q query_option] [-R address] [-S ctl_path] [-W host:port]
           [-w local_tun[:remote_tun]] destination [command]

@studgeek
Copy link

From what I can tell its not reading the config file since I don't get an error even if I give it a invalid filename?

$ bin/sshping -F FILEDOESNOTEXIST myhostname
*** Error connecting: Failed to resolve hostname myhostname (nodename nor servname provided, or not known)
*** Cannot establish ssh session

@waazaawaazaa
Copy link

@spook : May this also be an instance of #28 ? It seems that your config does not have Port specified, while the config of @labs-stellios does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants