Remote login via ssh and public keys

I'm not exactly a UNIX expert, but I need to be able to remote login to my PowerBook. The problem with enabling ssh is that as soon as I'm on campus, all kinds of nefarious hosts try brute force attempts to crack my password. I've heard that public/private key logins are the answer, and I've managed to get the public key in the right place on my PowerBook (the private key resides on my iPhone, from which I'll be logging in). But I have two questions:
1) How do I disable logins via user/password?
2) When I use my private key, I'm asked to enter the password for the key -- ssh isn't properly storing that password. I've checked permissions, but how can I get ssh to store that password, as it should?

1) In Sharing > Remote Login, do I still need an account listed to be able to use ssh logins with a public key? I ask because currently (i.e. password authentication enabled), when no accounts are listed, login via public key doesn't work. In other words, an account has to be listed for public key logins to work.
Yes you still need an account name to login to that computer. However you don't need to specify an account in the sharing preferences. You can lock down the security further by limiting which user accounts can login via ssh.
by default if you don't specify a username when you login it will use the username of the device your logging in from. So to use an alternative login name you would use
ssh [email protected]
whereas john can be anyname or your choosing.
Put another way: if turn off password authentication for ssh in sshd_config, how should Sharing > Remote Login be configured?
If you turn off password authentication you still need to allow your user account to login via ssh in the sharing preferences or you can allow all.
2) According to that MacOS X Hints article:
"Leopard has now a built-in support for SSH authentication with public keys.
OSX has been able to use ssh public key authentication since day 1 of the beta release of osx. It is not new to leopared it has been around for years.
Just open Terminal and ssh to your public-key-enabled server. A Keychain window appears, proposing you to enter the pass phrase, and then remembering it in your keychain. "
I have not used this functionality as I don't use any passwords for ssh logins.
They're talking about the password associated with the key. But on second thought, that password is being saved on the client, not the server, right?
I am sure this is the case.

Similar Messages

  • How do I configure Kwallet to manage SSH and GPG keys? [SOLVED]

    I'm using a select few KDE programs (not the DE) such as Kontact (and with that KMail, Korganizer, Kaddressbook...) and Kwallet. I've got a GPG and an SSH key which I need in Git to sign commits and push. I'd like to have Kwallet manage ALL of these passwords/passphrases, (e-mail, SSH, GPG) and only be prompted for a password to unlock my wallet once per session - or better yet, have the wallet unlocked by logging in (like the keychain in OS X). I'm currently using SLiM (systemd, slim.service) as the login manager. I had a glance at this tutorial for inspiration but to no success...
    This is my ~/.xinitrc:
    #!/bin/sh
    if [ -d /etc/X11/xinit/xinitrc.d ]; then
    for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
    done
    unset f
    fi
    # Hide mouse cursor when idle
    unclutter -idle 4 &
    # Background image
    hsetroot -fill $HOME/img/08.jpg &
    # Window manager
    xmonad
    This is my ~/.zprofile (failed attempt, fake GPG-key name)
    #!/bin/sh
    # Load keychain to handle ssh and gpg keys
    export SSH_ASKPASS=/usr/bin/ksshaskpass
    eval `keychain --eval id_rsa 1234ABCD`
    $HOME/.keychain/`hostname`-sh
    $HOME/.keychain/`hostname`-sh-gpg
    This is my ~/.gnupg/gpg.conf (commented lines not included)
    no-greeting
    require-cross-certification
    charset utf-8
    keyserver hkp://keys.gnupg.net
    Last edited by totte (2012-10-25 10:49:52)

    No success so far, really, need more ideas.
    Neither of /etc/kde/env/{gpg,ssh}-agent-startup.sh seem to be run by anything automatically on my system upon boot and logging in. I tried going back to the beginning and I got GPG working alright, when signing a commit I was automatically authenticated. SSH however still prompts me by CLI to enter my passphrase when I try to git-push or ssh into a server. I set an empty password for the wallet to have it "unlocked by logging in". I thought setting "export SSH_ASKPASS='/usr/bin/ksshaskpass'" in ~/.zprofile would have it prompt for the password in some manner of Qt window related to Kwallet, but apparently it doesn't. In top both ssh-agent and gpg-agent are displayed as running - but if I run gpg-agent in Konsole I get the output "gpg-agent: no gpg-agent running in this session", ssh-agent on the other hand outputs "SSH_AUTH_SOCK=/tmp/ssh-noaDS3C4AP8M/agent.1830; export SSH_AUTH_SOCK;
    SSH_AGENT_PID=1831; export SSH_AGENT_PID;
    echo Agent pid 1831;".
    Here's my ~/.zprofile, ~/.xinitrc, ~/.gnupg/gpg.conf, ~/.gnupg/gpg-agent.conf and ~/.zshrc (probably irrelevant but included anyway):
    ~/.zprofile
    export EDITOR='vim'
    export GIT_EDITOR='vim -fg'
    export GPG_TTY=$(tty)
    export GREP_COLOR='1;34'
    export GREP_OPTIONS='--color=auto'
    export LANG='en_GB.UTF-8'
    export PAGER='less'
    export PINENTRY='/usr/bin/pinentry-kwallet'
    export SSH_ASKPASS='/usr/bin/ksshaskpass'
    export VISUAL='vim'
    ~/.xinitrc
    #!/bin/sh
    if [ -d /etc/X11/xinit/xinitrc.d ]; then
    for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
    done
    unset f
    fi
    # Kwallet
    kwalletd &
    # Keychain (SSH & GPG)
    eval `keychain --eval id_rsa 1234ABCD` &
    # Hide mouse cursor when idle
    unclutter -idle 4 &
    # Background image
    hsetroot -fill $HOME/img/08.jpg &
    # Akonadi
    akonadictl start &
    # Music Player Daemon
    mpd &
    # Window manager
    xmonad
    ~/.gnupg/gpg.conf
    no-greeting
    require-cross-certification
    charset utf-8
    keyserver hkp://keys.gnupg.net
    use-agent
    ~/.gnupg/gpg-agent.conf
    pinentry-program /usr/bin/pinentry-kwallet
    no-grab
    ~/.zshrc (probably irrelevant)
    # PATH
    # System executables
    PATH0="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
    # My executables
    PATH1="$HOME/bin"
    export PATH="$PATH0:$PATH1"
    # COLOURS
    autoload colors; colors;
    eval "`dircolors -b ~/.dircolorsrc`"
    # GENERAL
    HISTFILE=$HOME/.zsh_history
    HISTSIZE=10000
    SAVEHIST=10000
    setopt append_history
    setopt extended_history
    setopt hist_expire_dups_first
    setopt hist_ignore_dups
    setopt hist_ignore_space
    setopt hist_verify
    setopt inc_append_history
    setopt share_history
    setopt prompt_subst
    setopt correctall
    setopt auto_menu
    setopt complete_in_word
    setopt always_to_end
    setopt extendedglob
    # ALIASES
    alias rezsh='. ~/.zshrc'
    alias _='sudo '
    alias l='ls -lh --color'
    alias la='ls -lAh --color'
    alias -- -='cd -'
    alias ..='cd ..'
    alias df='df -h'
    alias g='git'
    alias tmux='tmux attach'
    alias cp='cp -v'
    alias mv='mv -v'
    alias rm='rm -v'
    alias rmdir='rmdir -v'
    alias d='dirs -v'
    bu(){cp -v $1 ${1}.backup}
    cmds(){history | awk '{print $2}' | sort | uniq -c | sort -rn | head}
    md(){mkdir -p $1; cd $1}
    # OS-specific aliases
    if [[ $(uname) == "Darwin" ]]; then
    # Mac OS X
    alias pkgs='port search' # Search
    alias pkgi='sudo port install' # Install
    alias pkgu='sudo port selfupdate && sudo port upgrade outdated' # Update & Upgrade
    alias pkgr='sudo port uninstall --follow-dependencies' # Remove package and unused dependencies
    alias pkgl='port installed' # List installed packages
    alias python='/usr/local/bin/python3'
    alias pip='pip-3.2'
    alias pips='pip-3.2 search'
    alias pipi='pip-3.2 install'
    alias pipu='pip-3.2 install -U'
    alias pipr='pip-3.2 uninstall'
    alias pipl='pip-3.2 freeze'
    alias v='mvim'
    elif [[ $(uname) == "Linux" ]]; then
    alias pips='pip search'
    alias pipi='pip install'
    alias pipu='pip install -U'
    alias pipr='pip uninstall'
    alias pipl='pip freeze'
    alias v='vim'
    case $(lsb_release -d | cut -f2 | cut -d " " -f1) in
    (Arch) # Arch Linux
    alias equa='alsamixer -D equal'
    alias pkgs='pacman -Ss' # Search
    alias pkgi='sudo pacman -S' # Install
    alias pkgu='sudo pacman -Syu' # Update & Upgrade
    alias pkgr='sudo pacman -Rns' # Remove package, configuration backups and unused dependencies
    alias pkgl='pacman -Q' # List installed packages
    alias pkgd='whoneeds' # List packages depending on specified package
    alias poweroff='sudo systemctl poweroff'
    alias reboot='sudo systemctl reboot'
    alias nw='wicd-curses'
    (Debian|Ubuntu) # Debian and Ubuntu
    alias pkgs='aptitude search' # Search
    alias pkgi='sudo aptitude install' # Install
    alias pkgu='sudo aptitude update && sudo aptitude upgrade' # Update & Upgrade
    alias pkgr='sudo aptitude purge' # Remove package, configuration files and unused dependencies
    alias pkgl='aptitude search -F "%p" "~i"' # List installed packages
    alias reboot='sudo shutdown -r now'
    alias shutdown='sudo shutdown -h now'
    esac
    fi
    # Host-specific aliases
    if [[ ${HOST:r} == "betre" ]]; then
    alias poff='sudo /sbin/write-magic 0xdeadbeef && sudo /sbin/reboot'
    fi
    # TAB COMPLETION
    autoload compinit
    compinit
    # Case-insensitive (all),partial-word and then substring completion
    zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
    zstyle ':completion:*:*:*:*:*' menu select
    zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
    cdpath=(.)
    # Use /etc/hosts and known_hosts for hostname completion
    [ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
    [ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
    [ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
    hosts=(
    "$_global_ssh_hosts[@]"
    "$_ssh_hosts[@]"
    "$_etc_hosts[@]"
    `hostname`
    localhost
    zstyle ':completion:*:hosts' hosts $hosts
    # KEYBINDINGS
    bindkey '^[[A' history-beginning-search-backward
    bindkey '^[[B' history-beginning-search-forward
    bindkey "^[[H" beginning-of-line
    bindkey "^[[1~" beginning-of-line
    bindkey "^[OH" beginning-of-line
    bindkey "^[[F" end-of-line
    bindkey "^[[4~" end-of-line
    bindkey "^[OF" end-of-line
    # Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~
    bindkey '^?' backward-delete-char
    bindkey "^[[3~" delete-char
    bindkey "^[3;5~" delete-char
    bindkey "\e[3~" delete-char
    # TITLES
    tmux_title="%16<..<%~%<<"
    term_tab_title="%m"
    term_title="Terminal"
    function title(){
    if [[ "$TERM" == screen* ]]; then
    print -Pn "\ek$tmux_title:q\e\\"
    elif [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
    print -Pn "\e]2;$term_title:q\a"
    print -Pn "\e]1;$term_tab_title:q\a"
    fi
    function title_precmd(){
    title $tmux_title $term_tab_title $term_title
    function title_preexec(){
    emulate -L zsh
    setopt extended_glob
    local tmux_title=${1[(wr)^(*=*|sudo|ssh|-*)]}
    title $tmux_title $term_tab_title $term_title
    # ZSH VCS_INFO MODULE
    autoload -Uz vcs_info
    #zstyle ':vcs_info:*+*:*' debug true
    zstyle ':vcs_info:*' enable git
    zstyle ':vcs_info:git*' formats '%fon $(rou)%b%f%c%u%m'
    zstyle ':vcs_info:git*' actionformats '%fon $(rou)%b%f:$(rou)%a%f%c%u%m'
    zstyle ':vcs_info:git*:*' stagedstr ' (staged)'
    zstyle ':vcs_info:git*:*' unstagedstr ' (unstaged)'
    zstyle ':vcs_info:git*:*' get-revision true
    zstyle ':vcs_info:git*:*' check-for-changes true
    zstyle ':vcs_info:git*+set-message:*' hooks git-stash git-untracked
    # Display count of stashed changes
    function +vi-git-stash(){
    local -a stashes
    if [[ -s ${hook_com[base]}/.git/refs/stash ]] ; then
    stashes=$(git stash list 2>/dev/null | wc -l)
    if [[ $stashes > 1 ]] ; then
    hook_com[misc]+=" (${stashes} stashes)"
    else
    hook_com[misc]+=" (${stashes} stash)"
    fi
    fi
    # Display message if untracked files are present
    function +vi-git-untracked(){
    if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
    git status --porcelain | grep '??' &> /dev/null ; then
    hook_com[unstaged]+=" (untracked files present)"
    fi
    function prompt_precmd(){
    vcs_info
    # PROMPT
    # Root or user?
    function rou(){
    if [[ $UID -eq 0 ]] ; then
    echo "%{$fg[magenta]%}"
    else
    echo "%{$fg[blue]%}"
    fi
    # Display ± if we're in a git repository and » at all other times
    function prompt_character(){
    git branch >/dev/null 2>/dev/null && echo '%{$fg[white]%}±%{$reset_color%}' && return
    echo '%{$fg[white]%}»%{$reset_color%}'
    # Set the prompt
    function set_prompt(){
    PROMPT="$(rou)%n %{$reset_color%}at $(rou)%m %{$reset_color%}in $(rou)%~ ${vcs_info_msg_0_}
    %{$reset_color%}$(prompt_character) "
    # HOOKS
    autoload -U add-zsh-hook
    add-zsh-hook preexec title_preexec
    add-zsh-hook precmd title_precmd
    add-zsh-hook precmd prompt_precmd
    add-zsh-hook precmd set_prompt

  • How to get the private and public key?

    there is my code,i want to get the public key and the private key �Cbut i could not find the the approprite method to solve the problem.
    import java.security.Key;
    import javax.crypto.Cipher;
    import java.security.KeyPairGenerator;
    import java.security.KeyPair;
    import java.security.Security;
    public class PublicExample {
    public static void main(String[] args) throws Exception {
    if (args.length != 1) {
    System.err.println("Usage:java PublicExample <text>");
    System.exit(1);
    byte[] plainText = args[0].getBytes("UTF8");
    System.out.println("\nStart generating RSA key");
    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
    keyGen.initialize(512);
    KeyPair key = keyGen.generateKeyPair();
    System.out.println("Finish generating RSA key");
    Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding", "BC");
    //System.out.println("\n" + cipher.getProvider().getInfo());
    System.out.println("\nStart encryption");
    cipher.init(Cipher.ENCRYPT_MODE, key.getPublic());
    byte[] cipherText = cipher.doFinal(plainText);
    System.out.println("Finish encryption:");
    System.out.println(new String(cipherText, "UTF8"));
    System.out.println("\nStart decryption");
    cipher.init(Cipher.DECRYPT_MODE, key.getPrivate());
    /*i want to get the private and public key in this method ,but i found the result was not
    the one i expected to get,how to solve the problem?
    thanks in advance!
    System.out.println("private key:" + key.getPrivate().toString());
    System.out.println("public key:" + key.getPublic().toString());
    byte[] newPlainText = cipher.doFinal(cipherText);
    System.out.println("Finish decryption:");
    System.out.println(new String(newPlainText, "UTF8"));
    thanks in advance!

    System.out.println("private key:" +
    " + key.getPrivate().toString());
    System.out.println("public key:" +
    + key.getPublic().toString());
    key.getPrivate() returns an instance of PrivateKey and key.getPublic() returns an instance of PublicKey. Since PublicKey and PrivateKey are interfaces then they will return one of the concrete implementations. Check out the Javadoc for PublicKey and PrivateKey.
    When you know which concreate implemenation you have then you can use the methods on that object (by appropriate casting) to find the information you want.

  • Problems running a particular app via ssh and remote X

    Got a few apps (including things like Matlab etc.) running off one of our Linux application servers.
    Am now trying to run Stata (using xstata-se) via SGD and it will simply not work.
    It works perfectly if you manually log in to the application server from a terminal with ssh -X and run the executable, but when using SGD, it connects, finds the application, says it's starting it, but then the connection to the Linux server is simply closed. The application session (with pause/play/X buttons etc.) remains even though an X window never appears.
    I've duplicated the Matlab application that works perfectly and simply changed the executable name, so nothing is configured differently but it still refuses to work, instead simply closing the connection.
    The /opt/tarantella/var/log/webtop.log on the specific SGD server shows that the app starts correctly, yet no X window ever appears - all other X apps work fine...
    I've found that there are errors logged in /opt/tarantella/var/log/wm_error.log with:
    X connection to unix:11.0 broken (explicit kill or server shutdown).
    Any ideas?
    Edited by: Hutch on 23-Feb-2011 07:28

    I was having the same issue with Eclipse. If I launched an xterm and then ran eclipse it worked fine but as a published application, it would die after showing the Eclipse splash screen for a second. Adding the ampersand to the end of the launch command fixed it. Strange.
    Thanks for following up your post with the fix. I don't think backgrounding the process from the SGD launcher would have ever occurred to me.

  • Allow privilleged users to enter into EXEC mode on login not working with public keys

    Hi,
    I have recently updated one of my Cisco ASA to v9.2(1) and noticed a function to get the perform authorization for exec shell access can do a auto-enable when logging in from ssh.
    The problem is that if I use a private/public key authentication with a user it won't do the auto-enable feature. If I login without keys and using my password, it jumps into privilleged exec mode as it should.
    Anyone else had this issue?
    Config:
    aaa authentication ssh console LOCAL
    aaa authorization exec LOCAL auto-enable
    username user password xxxxxx encrypted privilege 15
    username user attributes
     ssh authentication publickey 22:af:xxxxxx hashed
    Any answer will be highly appreciated. 
    P.S I'm totally new in this forum.

    Would you be able to open a TAC SR and once you do , Email me the SR no and i will look into this issue.
    [email protected]
    Thanks and Regards,
    Vibhor Amrodia

  • Remote login via terminal

    can someone tell me how i use Terminal to login into my Server (Running OS X Server 10.4.3) at home? i need to know what command to use and also, once logged in via terminal whatever commands i enter will be controlling the server and not the local machine, right? sorry for the basic question but whatcha gonna do? please help....
    john.

    I've never user /accessed OS X server, but Mac to Mac access (I believe) should be the same.
    Ensure that 'Remote Login - SSH' is enables on your Mac's firewall..... then in Terminal type;
    ssh username@servername (or IP address). this will prompt for a passord... which will be the remote username's password on the OS X server machine.
    Once you are on the remote server any commands you enter in that shell (the command prompt in Terminal) will be run on that server. Toexit from the remote machine just type 'exit'
    What are you trying to run on the remote machine... I may be able to assist
    Des

  • How to you prevent disabling remote login via managed preferences?

    this doesn't seem to be an obvious setting.
    i want to disable our users from disabling remote login on their machines. some of them know how to do this.
    everyone has moblie home accounts, btw.
    hope someone can help!
    thanks in advance.

    thanks for your response, Tony.
    your 2nd suggestion is more towards what i am looking to do.
    we have WGM with User, Computer, Groups, and Computer Groups. right now, we aren't managing any preferences and we do make the users local admins on their machines after their first login/Home Sync.
    i was hoping to add a manifest to WGM in Preferences/Details, but i am not sure if this is possible and if it is, i don't know how to do it.
    we have users in remote sites that connect to our network via vpn and sometimes i need to remotely access their machines. but i can't on those that turn it off, obviously.
    thanks again!

  • Central location for ssh authorized public keys?

    Hi guys,
    I have been studying how to use ssh, but this has been bothering me and I will really appreciate any help.
    When you generate public keys for users, they go to the ~/.ssh/authorized_keys . If you as root, want to take control of all users public keys, say you want to have a central location for all public keys. You want sshd to read all keys from a different location rather than ~/.ssh/authorized_keys.
    How will you go about doing this?
    Thanks for your help this.
    Arrey

    You're welcome and enjoy your 'practice' ;-)
    however, I forgot to mention that if you modify the /etc/ssh/sshd_config file, you should restart the sshd daemon.
    $0.01: Restart the SSH daemon FROM ANOTHER SHELL to keep an active/running shell on the system, to recover, just in case.
    $0.02: I suggest a two-steps approach to be sure that the sshd daemon is correctly restarted and the new ssh session is not picking up a thread that hasn't properly re-read the configuration
    # svcadm disable ssh; sleep 5; svcadm enable ssh
    HTH,
    Marco

  • How to logout remote server via SSH

    I have a server running flux, I just want to log it out (it auto-logs back in, no GDM screen). How do I do this if I'm connected to it via SSH? Again, I want to log out the server as though I would do ctrl+alt+backspace locally, but through SSH.
    TIA

    I just realised how you start your session by auto login, so my above answer was pretty useless. The way I manage my server with an occasional gui session is to just use gdm and start/stop the daemon as needed via ssh then switch to a vnc  or xdmcp session.

  • [SOLVED] Does my system allow remote login through SSH?

    I installed openssh some time ago, to be able to connect to my phone's storage (phone is the server). I didn't configure anything, just installed the package and connected to my phone using nautilus. Now I'm wondering, is my computer a ssh server now? Because I don't want remote login to my computer at all. The documentation is a little confusing for me on this one.
    Last edited by kox (2015-06-21 12:44:41)

    No, that is just showing the grep process... I fit was running, you'd get
    └─╼ ps aux | grep ssh
    jason 563 0.0 0.0 13316 320 ? Ss Jun20 0:00 ssh-agent
    root 2256 0.0 0.1 40420 4996 ? Ss Jun20 0:00 /usr/bin/sshd -D
    jason 25006 0.0 0.0 10948 2312 pts/4 S+ 19:11 0:00 grep --color=auto ssh
    The preferred way to check would be to query the status of the service:
    ┌─[Shiv ~ ]
    └─╼ systemctl status sshd
    ● sshd.service - OpenSSH Daemon
    Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: disabled)
    Active: active (running) since Sat 2015-06-20 07:28:25 NZST; 1 day 11h ago
    Main PID: 2256 (sshd)
    CGroup: /system.slice/sshd.service
    └─2256 /usr/bin/sshd -D
    Jun 20 07:28:25 Shiv systemd[1]: Started OpenSSH Daemon.
    Jun 20 07:28:25 Shiv systemd[1]: Starting OpenSSH Daemon...
    Jun 20 07:28:25 Shiv sshd[2256]: Server listening on 0.0.0.0 port XXXX.
    Jun 20 07:28:25 Shiv sshd[2256]: Server listening on :: port XXXX.

  • How to get the private and public keys to use recaptcha?

    I have registered with google to get a recaptcha for my website. All I got was the site key and secret key! Though I need to get the public and private key for muse!

    Hello,
    Please use site Key as "Public Key"and Secret key as "Private Key".
    Regards
    Vivek

  • How to find modulus(n) and public key exponent(e)Sor

    I did the following code:
    import java.security.*;
    class keypair
    public static void main(String args[])
    try {
            KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
            keyGen.initialize(1024);
            KeyPair keypair = keyGen.genKeyPair();
            PrivateKey privateKey = keypair.getPrivate();
            PublicKey publicKey = keypair.getPublic();
            System.out.println(publicKey);
    catch (java.security.NoSuchAlgorithmException e) {
    }It produced the following output:
    E:\java>java keypair
    Sun RSA public key, 1024 bits
    modulus: 104598424699919432698042124865237006532583108525971624656815039032375
    *68185931249899603942873174007833898125332457427834491991685017307342129730049040*
    *85039266578793603162921901877391682504673766949037045217194339504369288262569809*
    *64618725280325930282787918761626276736975012559809247463223114702205350103039131*
    public exponent: 65537
    How to parse modulus(n) and public exponent(e) from this output?
    Similarly when i print private key, it produces the following output:
    E:\java>java keypair
    Sun RSA private CRT key, 1024 bits
    modulus:          124578817060208658480856678950235831207402457067036419284514
    *60119309486714863949162442643168408523979997168613499493638925829235693238993015*
    *36861462235708805467117179894466762970147852286192228334073408407380525883650965*
    *26200137024900438305422984852314541271126647102071346646999343089444655087519613*
    *147762713*
    public exponent:  65537
    private exponent: 938527844532658207604152892230342202756165450473898580852699
    *91069268853864683730106242370135012901790500054313488639918623825755509450966957*
    *25996151023641565209086629652161258725723528561744214714448113895688480371394495*
    *69970533766968335232379493089928062691491508442909468663624841001227918721233934*
    *90451285*
    prime p:          128112715803862066344339615342766575233634768887073748611821
    *70613165835421234259251719401979554816266892921739504796026180704477109334458578*
    *924582228715587*
    prime q:          972415706579323990162180646771186062588725555167352041581263
    *11833654947284058644791019214876691698044764118648637510099163830088827138987158*
    *06445271350899*
    prime exponent p: 102053075991522697645186596252261651077210381075096084960080
    *01572103324900452503753532555651687424478224695551102238145517644352533224205327*
    *850477437666141*
    prime exponent q: 668659136319899226645386130685620335239039277715133737489656
    *56694442226518700929665796129185316864860876985624927131126216000167126890435269*
    *81971346772483*
    crt coefficient:  337801534982286124613379128447816812903646302193598735486466
    *78634104811105616496519276355880320340688935923186965279527763125244878069735173*
    *60542121091569*
    E:\java>
    From this output how to parse n and d, where d is the secret exponent or decryption exponent? Thanks in advance. Apologies, for posting in this forum instead of cryptography forum.
    Edited by: sowndar on Nov 28, 2009 3:12 AM

    sowndar wrote:
    From this output how to parse n and d, where d is the secret exponent or decryption exponent? Why do you think you need to parse anything? Why do you need the modulus and exponents?
    P.S. Extract the public and private keys from the key pair, cast them to RSAPublicKey and RSAPrivateKey as appropriate then look at the methods of classes RSAPublicKey and RSAPrivateKey to see how to get modulus and exponents.

  • [SOLVED] razercfg, AUR and public keys.

    Hello!
    I am wandering about AUR package razercfg, recently is failed to build with error:
    ==> Verifying source file signatures with gpg...
    razercfg-0.31.tar.bz2 ... FAILED (unknown public key 5FB027474203454C)
    ==> ERROR: One or more PGP signatures could not be verified!
    ==> ERROR: Makepkg was unable to build razercfg.
    In the comments to the package I read maintainer's note:
    Import the author's key if you want makepkg to verify the source tarball:
    http://bues.ch/cms/resources/contact.html#gnupg_pgp_key
    So I went to http://bues.ch/cms/resources/contact.html#gnupg_pgp_key and found:
    My PGP key has got the ID number 908D8B0E. It can be obtained from most public key servers like keys.gnupg.net or directly from this site.
    So I imported it like that:
    $ gpg --keyserver hkp://keys.gnupg.net/ --recv-key 908D8B0E
    gpg: key 908D8B0E: public key "Michael Büsch <[email protected]>" imported
    gpg: no ultimately trusted keys found
    gpg: Total number processed: 1
    gpg: imported: 1
    The package is still failing to build with the same error. Afterwards I read notes by other users suggesting to import (another?) key:
    gpg --keyserver hkp://keys.gnupg.net/ --recv-key 5FB027474203454C
    I as understand 5FB027474203454C is the key mentioned in pkgbuild. But the author's page from the package maintainer's note suggests to import 908D8B0E not 5FB027474203454C. Could anyone help me please figure this out?
    Last edited by Ajunta (2015-03-15 19:58:14)

    Thy not use pacman-key? https://wiki.archlinux.org/index.php/Pacman-key
    Edit: Is it because you've read https://wiki.archlinux.org/index.php/Ma … e_checking ?
    I just googled the last 8 chars of validpgpkeys mentioned in the PKGBUILD in the AUR and got http://bues.ch/cms/resources/git.html - it's the key the author uses for git projects.
    Edit:
    $ sudo pacman-key -r 4203454C
    gpg: key 4203454C: public key "Michael Büsch (Git tag signing key) <[email protected]>" imported
    gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
    <snip>
    Last edited by karol (2015-03-14 13:34:58)

  • Cannot login via ssh/sftp from certain clients

    Hi Guys,
    Strange issue here. I have a machine running 10.7.4 that I want to be able to access via sftp/ssh.
    I can login into the machine in terminal using either ssh or sftp.
    I cannot however login to the machine from finder via sftp. I am just told the username/password is wrong.
    Equally I cannot login to the machine from certain clients on my android phone (the main reason I need sftp)
    I can however login from cyberduck on the other machines I have, and from some clients on my android phone.
    When a mac is denied access it gives authentication failed as the reason, when a android client is denied access it gives network communtaction issues as its reason for failing, not authentication.
    From memory these issues started when smb broke for me in 10.7.3.
    Can any one shed any light on this?
    Cheers

    bump

  • Is it possible to run a remote app via ssh?

    If I ssh from my Macbook Pro to my iMac, I can run the xclock command like this:
    ssh -X imac
    /usr/X11/bin/xclock
    Is it possible to do something similar with a .app application?  If I ssh in and use the "open" command to open the calculator, it opens on the Mac, but I can't see it from my Macbook:
    open -a Calculator.app

    The closest thing to that is Screen Sharing.

Maybe you are looking for