Comments (1)
As far as I remember there is no support for SSH keys by the SSH server in MockSSH and the keys you are seeing are the server's and not the client's.
If you want this feature I would be willing to implement it but please see if you can contribute a patch first by integrating the following into something reusable:
(mockssh)jehjohnson ~/git/MockSSH $ ckeygen -t rsa -f id_rsa
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa
Your public key has been saved in id_rsa.pub
The key fingerprint is:
fc:b8:57:88:ed:b6:46:df:71:f3:65:67:19:bd:41:45
In MockSSH.py under the password checker:
sshFactory.portal.registerChecker(
checkers.InMemoryUsernamePasswordDatabaseDontUse(**users))
Add the following to add support for the new keys created, for the user me:
sshFactory.portal.registerChecker(
SSHPublicKeyChecker(
InMemorySSHKeyDB({
'me': [keys.Key.fromFile('id_rsa.pub')]})))
Run a MockSSH server:
$ python MockSSH.py
Test public key authentication:
jehjohnson ~ $ ssh me@0 -p 2222 -v -i ~jehjohnson/git/MockSSH/id_rsa
OpenSSH_6.7p1 Debian-5+deb8u2, OpenSSL 1.0.1t 3 May 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 0 [0.0.0.0] port 2222.
debug1: Connection established.
debug1: identity file /home/jehjohnson/git/MockSSH/keys/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jehjohnson/git/MockSSH/keys/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Debian-5+deb8u2
debug1: Remote protocol version 2.0, remote software version OpenSSH_Mock MockSSH.py
debug1: match: OpenSSH_Mock MockSSH.py pat OpenSSH* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha2-256 none
debug1: kex: client->server aes128-ctr hmac-sha2-256 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<8192<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA e6:2f:4f:c3:8e:44:ba:7d:2d:83:c3:b8:11:79:3d:60
debug1: Host '[0]:2222' is known and matches the RSA host key.
debug1: Found key in /home/jehjohnson/.ssh/known_hosts:21
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password,publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/janedoe/git/MockSSH/keys/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 151
debug1: Authentication succeeded (publickey).
Authenticated to 0 ([127.0.0.1]:2222).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
$ exit
debug1: SSH2_MSG_KEXINIT sent
debug1: channel 0: free: client-session, nchannels 1
Connection to 0 closed.
Transferred: sent 4440, received 3496 bytes, in 167.7 seconds
Bytes per second: sent 26.5, received 20.8
debug1: Exit status -1
janedoe ~ $
from mockssh.
Related Issues (17)
- mocksshy and command validation HOT 2
- When importing MockSSH: ImportError: No module named conch HOT 1
- Add instructions to generate primes and keys (and where to store them) HOT 1
- add support for Diffie-Hellman prime groups as required by twisted.conch.ssh.factory
- Add optionnal banner while authenticating HOT 4
- Python3 support HOT 1
- execCommand support HOT 15
- support commands with PIPE HOT 4
- Packaging for PyPi HOT 7
- Question: How to run server that does not require password? HOT 1
- Getting OSError: [Errno 9] Bad file descriptor in tests HOT 1
- Python3 continued HOT 2
- Rename PasswordPromptingCommand to PromptingCommand
- Rename ArgumentValidatingCommand as SSHCommand HOT 1
- Implement unit tests HOT 4
- Rename new functions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mockssh.