A publickey pipe will cause re-mapping to fail in kubernetes
Closed this issue · 5 comments
I created sshpiper
and two test pods using the following files in k8s:
sshpiper-service.yaml
: Used to launchsshpiper
.password-test.yaml
: Only for password login.publickey-test.yaml
: For login using either a public key or a password.
If I only start items 1 and 2, I can normally log in using ssh password_test@127.0.0.1 -p 30022
.
However, if I enable item 3, then I must use ssh password_test@127.0.0.1 -p 30022 -o PubkeyAuthentication=no
to log in.
I saw a similar issue in #12 , and it seems to have been resolved. Did I configure something incorrectly?
# sshpiper-service.yaml
---
# sshpiper Service
apiVersion: v1
kind: Service
metadata:
name: sshpiper
spec:
selector:
app: sshpiper
ports:
- protocol: TCP
port: 2222
targetPort: 2222
nodePort: 30022
type: NodePort
---
apiVersion: v1
data:
server_key: |
LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFBQUFBQkc1dmJtVUFBQUFFYm05dVpRQUFBQUFBQUFBQkFBQUFNd0FBQUF0emMyZ3RaVwpReU5UVXhPUUFBQUNCWUhWV01lNzVDZ3Rzdm5rOWlTekJFU3hSdjdMb3U3K0tVbndmb3VnNzcxZ0FBQUpEQnArS0d3YWZpCmhnQUFBQXR6YzJndFpXUXlOVFV4T1FBQUFDQllIVldNZTc1Q2d0c3ZuazlpU3pCRVN4UnY3TG91NytLVW53Zm91Zzc3MWcKQUFBRUJKSDU3eTFaRTUxbVo2a2VsWUR0eDQ1ajBhZGdsUk5CY0pZOE94YTY4TEJWZ2RWWXg3dmtLQzJ5K2VUMkpMTUVSTApGRy9zdWk3djRwU2ZCK2k2RHZ2V0FBQUFEV0p2YkdsaGJrQjFZblZ1ZEhVPQotLS0tLUVORCBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0K
kind: Secret
metadata:
name: sshpiper-server-key
type: Opaque
---
# sshpiper Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: sshpiper-deployment
labels:
app: sshpiper
spec:
replicas: 1
selector:
matchLabels:
app: sshpiper
template:
metadata:
labels:
app: sshpiper
spec:
serviceAccountName: sshpiper-account
containers:
- name: sshpiper
image: farmer1992/sshpiperd:full-v1.3.0
ports:
- containerPort: 2222
env:
- name: PLUGIN
value: "kubernetes"
- name: SSHPIPERD_SERVER_KEY
value: "/serverkey/ssh_host_ed25519_key"
- name: SSHPIPERD_LOG_LEVEL
value: "trace"
volumeMounts:
- name: sshpiper-server-key
mountPath: "/serverkey/"
readOnly: true
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
volumes:
- name: sshpiper-server-key
secret:
secretName: sshpiper-server-key
items:
- key: server_key
path: ssh_host_ed25519_key
---
# Role
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: sshpiper-reader
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get"]
- apiGroups: ["sshpiper.com"]
resources: ["pipes"]
verbs: ["get", "list", "watch"]
---
# RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-sshpiper
subjects:
- kind: ServiceAccount
name: sshpiper-account
roleRef:
kind: Role
name: sshpiper-reader
apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: sshpiper-account
# password-test.yaml
---
# Pipe
apiVersion: sshpiper.com/v1beta1
kind: Pipe
metadata:
name: pipe-password
spec:
from:
- username: "password_test"
to:
host: pipe-password:2222
username: "user"
ignore_hostkey: true
---
apiVersion: v1
kind: Service
metadata:
name: pipe-password
spec:
selector:
app: pipe-password
ports:
- protocol: TCP
port: 2222
---
# sshd Pod
apiVersion: v1
kind: Pod
metadata:
name: pipe-password
labels:
app: pipe-password
spec:
containers:
- name: pipe-password
imagePullPolicy: IfNotPresent
image: lscr.io/linuxserver/openssh-server:latest
ports:
- containerPort: 2222
env:
- name: PASSWORD_ACCESS
value: "true"
- name: USER_PASSWORD
value: "pass"
- name: USER_NAME
value: "user"
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
# publickey-test.yaml
---
apiVersion: v1
data:
ssh-privatekey: |
LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFBQUFBQkc1dmJtVUFBQUFFYm05dVpRQUFBQUFBQUFBQkFBQUFNd0FBQUF0emMyZ3RaVwpReU5UVXhPUUFBQUNCOHhKd1BtZXBvZFpoV2lMM2t0anN2UGM0ZGgwUk4wWTZTT3d0eUI3bkFwUUFBQUpqVEhRN3EweDBPCjZnQUFBQXR6YzJndFpXUXlOVFV4T1FBQUFDQjh4SndQbWVwb2RaaFdpTDNrdGpzdlBjNGRoMFJOMFk2U093dHlCN25BcFEKQUFBRUQzRE9yaWZSazQ1NVMxZkdyaHZ5bk15QmQwaHJmMXo5OWM2aG0yS2pVaC8zekVuQStaNm1oMW1GYUl2ZVMyT3k4OQp6aDJIUkUzUmpwSTdDM0lIdWNDbEFBQUFFWFJsYzNSQWMzTm9jR2x3WlhJdVkyOXRBUUlEQkE9PQotLS0tLUVORCBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0K
kind: Secret
metadata:
name: pipe-publickey-key
type: kubernetes.io/ssh-auth
---
# Pipe
apiVersion: sshpiper.com/v1beta1
kind: Pipe
metadata:
name: pipe-publickey
annotations:
privatekey_field_name: ssh-privatekey # this is optional, default is ssh-privatekey
spec:
from:
- username: "publickey_test"
authorized_keys_data: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHzEnA+Z6mh1mFaIveS2Oy89zh2HRE3RjpI7C3IHucCl test@sshpiper.com"
to:
host: pipe-publickey:2222
username: "user"
private_key_secret:
name: pipe-publickey-key
ignore_hostkey: true
---
apiVersion: v1
kind: Service
metadata:
name: pipe-publickey
spec:
selector:
app: pipe-publickey
ports:
- protocol: TCP
port: 2222
---
apiVersion: v1
kind: Pod
metadata:
name: pipe-publickey
labels:
app: pipe-publickey
spec:
containers:
- name: pipe-publickey
image: lscr.io/linuxserver/openssh-server:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 2222
env:
- name: USER_NAME
value: "user"
- name: PASSWORD_ACCESS
value: "true"
- name: USER_PASSWORD
value: "pass"
- name: PUBLIC_KEY
value: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHzEnA+Z6mh1mFaIveS2Oy89zh2HRE3RjpI7C3IHucCl test@sshpiper.com"
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
I have observed that when a default private key, such as id_rsa
, exists in the ~/.ssh
directory, sshpiper
continuously receives downstream 10.244.0.1:63567 (username [password_test]) is sending public key auth
, and it cannot proceed to the password phase.
could you please share ssh -v password_test@xxx
by default ssh client will try password if key failed, server side (sshpiper) should ask for password
could you please share ssh -v password_test@xxx
by default ssh client will try password if key failed, server side (sshpiper) should ask for password
Here is the output of ssh -v password_test@127.0.0.1 -p 30022
.
OpenSSH_8.2p1 Ubuntu-4ubuntu0.5, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 30022.
debug1: Connection established.
debug1: identity file ~/.ssh/id_rsa type 0
debug1: identity file ~/.ssh/id_rsa-cert type -1
debug1: identity file ~/.ssh/id_dsa type -1
debug1: identity file ~/.ssh/id_dsa-cert type -1
debug1: identity file ~/.ssh/id_ecdsa type -1
debug1: identity file ~/.ssh/id_ecdsa-cert type -1
debug1: identity file ~/.ssh/id_ecdsa_sk type -1
debug1: identity file ~/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file ~/.ssh/id_ed25519 type -1
debug1: identity file ~/.ssh/id_ed25519-cert type -1
debug1: identity file ~/.ssh/id_ed25519_sk type -1
debug1: identity file ~/.ssh/id_ed25519_sk-cert type -1
debug1: identity file ~/.ssh/id_xmss type -1
debug1: identity file ~/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.5
debug1: Remote protocol version 2.0, remote software version SSHPiper
debug1: no match: SSHPiper
debug1: Authenticating to 127.0.0.1:30022 as 'password_test'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-ed25519 SHA256:hoA5YVIYn6HLkLOH7MN30gqm+9sA3KBfrdE6hT9itzs
debug1: Host '[127.0.0.1]:30022' is known and matches the ED25519 host key.
debug1: Found key in ~/.ssh/known_hosts:14
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: ~/.ssh/id_rsa RSA SHA256:UPHGlpdDRyO8YXBSIxAWKASS8dwJ0cl5hey+y3d54Mg
debug1: Will attempt key: ~/.ssh/id_dsa
debug1: Will attempt key: ~/.ssh/id_ecdsa
debug1: Will attempt key: ~/.ssh/id_ecdsa_sk
debug1: Will attempt key: ~/.ssh/id_ed25519
debug1: Will attempt key: ~/.ssh/id_ed25519_sk
debug1: Will attempt key: ~/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-256,rsa-sha2-512,ssh-rsa,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password,publickey
debug1: Next authentication method: publickey
debug1: Offering public key: ~/.ssh/id_rsa RSA SHA256:UPHGlpdDRyO8YXBSIxAWKASS8dwJ0cl5hey+y3d54Mg
debug1: Server accepts key: ~/.ssh/id_rsa RSA SHA256:UPHGlpdDRyO8YXBSIxAWKASS8dwJ0cl5hey+y3d54Mg
Authenticated with partial success.
debug1: Authentications that can continue: password,publickey
debug1: Trying private key: ~/.ssh/id_dsa
debug1: Trying private key: ~/.ssh/id_ecdsa
debug1: Trying private key: ~/.ssh/id_ecdsa_sk
debug1: Trying private key: ~/.ssh/id_ed25519
debug1: Trying private key: ~/.ssh/id_ed25519_sk
debug1: Trying private key: ~/.ssh/id_xmss
debug1: Offering public key: ~/.ssh/id_rsa RSA SHA256:UPHGlpdDRyO8YXBSIxAWKASS8dwJ0cl5hey+y3d54Mg
debug1: Server accepts key: ~/.ssh/id_rsa RSA SHA256:UPHGlpdDRyO8YXBSIxAWKASS8dwJ0cl5hey+y3d54Mg
Authenticated with partial success.
debug1: Authentications that can continue: password,publickey
debug1: Trying private key: ~/.ssh/id_dsa
debug1: Trying private key: ~/.ssh/id_ecdsa
debug1: Trying private key: ~/.ssh/id_ecdsa_sk
debug1: Trying private key: ~/.ssh/id_ed25519
debug1: Trying private key: ~/.ssh/id_ed25519_sk
debug1: Trying private key: ~/.ssh/id_xmss
debug1: Offering public key: ~/.ssh/id_rsa RSA SHA256:UPHGlpdDRyO8YXBSIxAWKASS8dwJ0cl5hey+y3d54Mg
debug1: Server accepts key: ~/.ssh/id_rsa RSA SHA256:UPHGlpdDRyO8YXBSIxAWKASS8dwJ0cl5hey+y3d54Mg
...
Only the unique part has been captured; the remaining part is an endless repetition of the following content:
Authenticated with partial success.
debug1: Authentications that can continue: password,publickey
debug1: Trying private key: ~/.ssh/id_dsa
debug1: Trying private key: ~/.ssh/id_ecdsa
debug1: Trying private key: ~/.ssh/id_ecdsa_sk
debug1: Trying private key: ~/.ssh/id_ed25519
debug1: Trying private key: ~/.ssh/id_ed25519_sk
debug1: Trying private key: ~/.ssh/id_xmss
debug1: Offering public key: ~/.ssh/id_rsa RSA SHA256:UPHGlpdDRyO8YXBSIxAWKASS8dwJ0cl5hey+y3d54Mg
debug1: Server accepts key: ~/.ssh/id_rsa RSA SHA256:UPHGlpdDRyO8YXBSIxAWKASS8dwJ0cl5hey+y3d54Mg
it should not fall into infinite loop to ask you to auth, let me mark it as a bug
could you please test v1.2.8 while i am looking into it? i am thinking if it is a regression caused by partial succ
it should not fall into infinite loop to ask you to auth, let me mark it as a bug
could you please test v1.2.8 while i am looking into it? i am thinking if it is a regression caused by partial succ
Nice, v1.2.8 runs perfectly.