[GH-ISSUE #378] System wide ssh_config support #215

Closed
opened 2026-02-26 23:58:50 +03:00 by kerem · 7 comments
Owner

Originally created by @ihipop on GitHub (Mar 30, 2018).
Original GitHub issue: https://github.com/electerm/electerm/issues/378

I'v defined a lot of host items in ~/.ssh/config
and I have a system wine ssh_agent started
Could you please display these items from ~/.ssh/config in electerm's bookmarks
( even read only items at first in a special category) and the ssh client will use System wide ssh_agent
That will provider a same experience both in command line native ssh client and electerm
and save a lot of time to migrate from command line

Originally created by @ihipop on GitHub (Mar 30, 2018). Original GitHub issue: https://github.com/electerm/electerm/issues/378 I'v defined a lot of host items in ` ~/.ssh/config` and I have a system wine `ssh_agent` started Could you please display these items from ` ~/.ssh/config` in `electerm's bookmarks` ( **even read only items at first** in a special category) and the ssh client will use System wide `ssh_agent` That will provider a same experience both in `command line native ssh client` and `electerm` and save a lot of time to migrate from `command line`
kerem 2026-02-26 23:58:50 +03:00
  • closed this issue
  • added the
    feature
    label
Author
Owner

@zxdong262 commented on GitHub (Mar 30, 2018):

would you please post a sample file of your ~/.ssh/config

<!-- gh-comment-id:377474921 --> @zxdong262 commented on GitHub (Mar 30, 2018): would you please post a sample file of your `~/.ssh/config`
Author
Owner

@ihipop commented on GitHub (Mar 30, 2018):

@zxdong262

You don‘t need to parse the items in ~/.ssh/config,there a some Utils/Libraries available.

For example ,I have these items in my ~/.ssh/config

ServerAliveInterval 15
ControlPath ~/.ssh/cm-%r@%h:%p
ControlMaster auto
ControlPersist 2m

Host github.com
	User git
	IdentityFile ~/.ssh/Git/id_rsa_git

#Example for SSH GateWay
Host Relay
	HostName xxx.xxx.xxx.xxx
	User root
	Port 2233
	LocalForward 2221 web-1:22
	LocalForward 2222 web-2:22
	#We don't define IdentityFile for this item because it use default ssh key
Host www-web-1
     	Hostname web-1
     	User root
     	Port 22
	ProxyJump Relay
	IdentityFile ~/.ssh/relay_rsa
Host www-web-2
     	Hostname web-2
     	User root
     	Port 22
	ProxyCommand ssh -W  %h:%p xinglin-Relay
	IdentityFile ~/.ssh/relay_rsa
Host svc-gitlab
	Hostname gitlab
	User root
	ProxyJump Relay	
	IdentityFile ~/.ssh/relay_rsa

#优酷路由宝
Host youku-LYB
	Hostname 192.168.123.1
	User admin
#VPS
Host pop-fremont-01
	Hostname example.com
	User abc
	Port 233

If I want to Connect to Host youku-LYB,I just type

ssh youku-LYB

the native ssh client will connect to 192.168.123.1 at port 22 use user root

If I want to Connect to Host pop-fremont-01 ,I just type

ssh pop-fremont-01

the native ssh client will connect to example.com at port 233 use user abc

And,For example,the Host www-web-1 is behind Host Relay ,I just type

ssh www-web-1

the native ssh client will connect to web-1 via Host Relay,the Hostname web-1 of Host www-web-1 will be resolved use the Host Relay

I can do some very complex config in ~/.ssh/config,and use it just with a simple name of Host

And ,Most Linux Desktop Have a global ssh-agent started, Means that if I only need to call ssh-add ~/.ssh/relay_rsa and enter the password only once. The next call of ~/.ssh/relay_rsa will handled by ssh-agent automaticly

If you can display Items of ~/.ssh/config,then simple call ssh command is just enough

You don‘t need to parse the items in ~/.ssh/config,there a some Utils/Libraries available.

<!-- gh-comment-id:377481283 --> @ihipop commented on GitHub (Mar 30, 2018): @zxdong262 **You don‘t need to parse the items in `~/.ssh/config`,there a some Utils/Libraries available.** For example ,I have these items in my `~/.ssh/config` ``` ServerAliveInterval 15 ControlPath ~/.ssh/cm-%r@%h:%p ControlMaster auto ControlPersist 2m Host github.com User git IdentityFile ~/.ssh/Git/id_rsa_git #Example for SSH GateWay Host Relay HostName xxx.xxx.xxx.xxx User root Port 2233 LocalForward 2221 web-1:22 LocalForward 2222 web-2:22 #We don't define IdentityFile for this item because it use default ssh key Host www-web-1 Hostname web-1 User root Port 22 ProxyJump Relay IdentityFile ~/.ssh/relay_rsa Host www-web-2 Hostname web-2 User root Port 22 ProxyCommand ssh -W %h:%p xinglin-Relay IdentityFile ~/.ssh/relay_rsa Host svc-gitlab Hostname gitlab User root ProxyJump Relay IdentityFile ~/.ssh/relay_rsa #优酷路由宝 Host youku-LYB Hostname 192.168.123.1 User admin #VPS Host pop-fremont-01 Hostname example.com User abc Port 233 ``` If I want to Connect to `Host youku-LYB`,I just type ```bash ssh youku-LYB ``` the native ssh client will connect to `192.168.123.1` at port `22` use user `root` If I want to Connect to `Host pop-fremont-01` ,I just type ```bash ssh pop-fremont-01 ``` the native ssh client will connect to `example.com` at port `233` use user `abc` And,For example,the `Host www-web-1` is behind `Host Relay` ,I just type ``` ssh www-web-1 ``` the native ssh client will connect to `web-1` via `Host Relay`,the Hostname `web-1` of `Host www-web-1` will be resolved use the `Host Relay` I can do some very complex config in `~/.ssh/config`,and use it just with a simple name of `Host` And ,Most Linux Desktop Have a global `ssh-agent` started, Means that if I only need to call `ssh-add ~/.ssh/relay_rsa ` and enter the password only once. The next call of `~/.ssh/relay_rsa` will handled by `ssh-agent` automaticly If you can display Items of `~/.ssh/config`,then simple call `ssh` command is just enough **You don‘t need to parse the items in `~/.ssh/config`,there a some Utils/Libraries available.**
Author
Owner

@ihipop commented on GitHub (Mar 30, 2018):

And add the support for ~/.ssh/config will let electerm to have the ability to access/upload files behind a ssh gateway,with a little code to write

<!-- gh-comment-id:377483907 --> @ihipop commented on GitHub (Mar 30, 2018): And add the support for ` ~/.ssh/config` will let `electerm` to have the ability to access/upload files behind a `ssh gateway`,with a little code to write
Author
Owner

@ihipop commented on GitHub (Apr 2, 2018):

@zxdong262 I downloaded the pre-release,but it not work correctly, It can only display the first item of ~/.ssh/config

github.com/electerm/electerm@fb086205dc/app/lib/ssh-config.js (L12-L42)

Manually parsed host name and port,catch (e) without log it,I can‘t provider any information...

<!-- gh-comment-id:377888959 --> @ihipop commented on GitHub (Apr 2, 2018): @zxdong262 I downloaded the pre-release,but it not work correctly, It can only display the first item of ` ~/.ssh/config` https://github.com/electerm/electerm/blob/fb086205dc1c76432161cba3d12029d67d497729/app/lib/ssh-config.js#L12-L42 Manually parsed host name and port,`catch (e)` without log it,I can‘t provider any information...
Author
Owner

@zxdong262 commented on GitHub (Apr 2, 2018):

@ihipop Hostname -> HostName will fix it. Hostname will be supported in next release.

<!-- gh-comment-id:377892237 --> @zxdong262 commented on GitHub (Apr 2, 2018): @ihipop `Hostname` -> `HostName` will fix it. Hostname will be supported in next release.
Author
Owner

@ihipop commented on GitHub (Apr 2, 2018):

@zxdong262
Hostname -> HostName fix the first issue,but still have problem with Host behind a Relay,because you Manually parsed host name and port, please see if this helps https://www.npmjs.com/package/ssh-config
Or even just consider call ssh HostItem command directly(this may not work for sftp because you use your own Interactive UI)

<!-- gh-comment-id:377895270 --> @ihipop commented on GitHub (Apr 2, 2018): @zxdong262 `Hostname` -> `HostName` fix the first issue,but still have problem with `Host` behind a `Relay`,because you Manually parsed host name and port, please see if this helps https://www.npmjs.com/package/ssh-config Or even just consider call `ssh HostItem` command directly(this may not work for sftp because you use your own Interactive UI)
Author
Owner

@zxdong262 commented on GitHub (Apr 2, 2018):

@ihipop thanks.

<!-- gh-comment-id:377904178 --> @zxdong262 commented on GitHub (Apr 2, 2018): @ihipop thanks.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/electerm#215
No description provided.