mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
chore: improve SSH_AUTH_SOCK reading on macOS
This commit is contained in:
@@ -9,6 +9,7 @@ import com.formdev.flatlaf.util.FontUtils
|
|||||||
import com.formdev.flatlaf.util.SystemInfo
|
import com.formdev.flatlaf.util.SystemInfo
|
||||||
import com.jgoodies.forms.builder.FormBuilder
|
import com.jgoodies.forms.builder.FormBuilder
|
||||||
import com.jgoodies.forms.layout.FormLayout
|
import com.jgoodies.forms.layout.FormLayout
|
||||||
|
import org.apache.commons.io.FileUtils
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.apache.commons.lang3.StringUtils
|
import org.apache.commons.lang3.StringUtils
|
||||||
import org.apache.sshd.client.ClientBuilder
|
import org.apache.sshd.client.ClientBuilder
|
||||||
@@ -231,6 +232,13 @@ object SshClients {
|
|||||||
|
|
||||||
// ssh-agent
|
// ssh-agent
|
||||||
if (host.authentication.type == AuthenticationType.SSHAgent) {
|
if (host.authentication.type == AuthenticationType.SSHAgent) {
|
||||||
|
if (SystemInfo.isMacOS) {
|
||||||
|
val file = FileUtils.getFile(Application.getBaseDataDir(), "config", "ssh_auth_sock.sock")
|
||||||
|
if (file.exists() && file.isFile) {
|
||||||
|
entry.setProperty(IDENTITY_AGENT, file.absolutePath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (entry.getProperty(IDENTITY_AGENT).isNullOrBlank()) {
|
||||||
if (host.authentication.password.isNotBlank())
|
if (host.authentication.password.isNotBlank())
|
||||||
entry.setProperty(IDENTITY_AGENT, host.authentication.password)
|
entry.setProperty(IDENTITY_AGENT, host.authentication.password)
|
||||||
else if (SystemInfo.isWindows)
|
else if (SystemInfo.isWindows)
|
||||||
@@ -238,6 +246,7 @@ object SshClients {
|
|||||||
else
|
else
|
||||||
entry.setProperty(IDENTITY_AGENT, UnixDomainSocketConnector.DESCRIPTOR.identityAgent)
|
entry.setProperty(IDENTITY_AGENT, UnixDomainSocketConnector.DESCRIPTOR.identityAgent)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val session = client.connect(entry).verify(timeout).session
|
val session = client.connect(entry).verify(timeout).session
|
||||||
if (host.authentication.type == AuthenticationType.Password) {
|
if (host.authentication.type == AuthenticationType.Password) {
|
||||||
|
|||||||
Reference in New Issue
Block a user