Showing posts with label SSH. Show all posts
Showing posts with label SSH. Show all posts

Friday, 29 December 2023

HTTPS(TLS) VS SSH

 HTTPS(TLS) encryption (TLS is upgraded version of ssl)


server sends client a certificate contains server name, server public IP, signature with CA info(signed by CA's private key) to client(Browser)


client has list of CA, and public key to decrypt the signature to verify CA.

Once verified, client creates a symmetric key, client encrypts with server's public key and send to server



server decrypts using servers private key, creates a session key and encrypt with server private key,

client can then use this session key decrypt with server public key



For two way, certification verification will be done on both side, then server creates session key encrypted with clients public key 


the secret key portion is symmetric :

 in symmetric key encryption, both the encryption and decryption are done with the same key, or the decryption 

In the case of asymmetric encryption, the public key can only be used for encrypting the message; you’ll need the private key for decrypting the message. 


SSH uses combination of both for security

https://blog.invgate.com/what-are-ssh-keys


SSH works similar but little differently

SSH uses both symmetric, and asymmetric

client need to have private key, and store public key on server

1) SSH secure connection using secret key

when client makes ssh request to server, server creates secret key and encrypt using client public key and send to client, client receives this key and decrepts using its private key, and data exchange from here on will use this secret key. 


2) once server acknolwedges client decrpyts symmetic key, server creates a msg, and encrypt with clients public key.

client decrypts this msg using client private key, then use this msg combine with secret key to create a hash and send to server

server will also create the same hash using the msg and secret key,  if two hash matches, user is authenticated





Tuesday, 28 November 2023

ssh host key changed how to fix

Offending ED25519 key in /c/Users/jxiang/.ssh/known_hosts:15

Host key for 172.16.100.53 has changed and you have requested strict checking.

Host key verification failed.



 vim .ssh/know_hosts


172.19.11.125 ecdsa-sha2-nistp256 xxxxxxxxxxxxxxxxxxxx



delete this entry and try ssh again, it will ask u to add 



Monday, 6 November 2023

open SSH VS OPENSSL

 https://security.stackexchange.com/questions/3424/how-is-openssl-related-to-openssh


OpenSSH is a program depending on OpenSSL the library, specifically OpenSSH uses the libcrypto part of OpenSSL.


It's worth mentioning that OpenSSH does not use the TLS protocol thats used for HTTPS etc. OpenSSH uses some of the OpenSSL cryptographic primatives.



https://kinsta.com/knowledgebase/ssh-vs-ssl/#:~:text=The%20key%20difference%20between%20SSH,as%20you%20can%20with%20SSH.


The key difference between SSH vs SSL is that SSH is used for creating a secure tunnel to another computer from which you can issue commands, transfer data, etc.

On the other end, SSL is used for securely transferring data between two parties – it does not let you issue commands as you can with SSH.

Monday, 30 October 2023

bash,git bash error - Pseudo-terminal will not be allocated because stdin is not a terminal

 Pseudo-terminal will not be allocated because stdin is not a terminal

is an error when you do ssh to a remote server and you dont have any terminal:

https://www.baeldung.com/linux/ssh-pseudo-terminal-allocation#:~:text=In%20this%20case%2C%20ssh%20doesn,ssh%20prints%20this%20error%20message.


A pseudo-terminal, pseudo-TTY, or simply pty is a device that emulates a physical terminal. It allows programs to interact with users as if they’re running on a real terminal, even if they’re not.


When we use ssh to connect to a remote machine, ssh allocates a pty on the remote machine and connects it to our local terminal. However, sometimes we may want to run a command on the remote machine without a terminal. For example, we may want to redirect the standard input (stdin) of the command from a file or another command.


In this case, ssh doesn’t allocate a pty on the remote machine, because stdin isn’t a terminal. This causes problems if the command we’re trying to run expects to be run in a terminal. The command may fail or behave unexpectedly, and ssh prints this error message.


solution:

https://stackoverflow.com/questions/7114990/pseudo-terminal-will-not-be-allocated-because-stdin-is-not-a-terminal

ssh -tt

-T      Disable pseudo-tty allocation.

-t      Force pseudo-tty allocation.  This can be used to execute arbitrary 
        screen-based programs on a remote machine, which can be very useful,
        e.g. when implementing menu services.  Multiple -t options force tty
        allocation, even if ssh has no local tty.

": If you provide commands to ssh via stdin, its stdin, due to the input redirection, is no longer connected to a terminal, so in that sense "ssh has no local tty" anymore. It is in this scenario that a single -t is insufficient to allocate a pty and -t -t (-tt) must be used instead."